I have a library that I used to build against different versions of .NET by executing a command line like this: msbuild x.csproj /p:TargetFrameworkVersion=v4.6.2 ...
multiple times with different value for the property TargetFrameworkVersion. Now I wanted to add .NET 4.7.1 to the script. The build for 4.7.1 succeeds but the next builds fail with a message like this:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\NuGet\15.0\Microsoft.NuGet.targets(186,5): error : Your project is not referencing the ".NETFramework,Version=v4.6.2" framework. Add a reference to ".NETFramework,Version=v4.6.2" in the "frameworks" section of your project.json, and then re-run NuGet restore. [x.csproj]
I searched for this message a lot but could not find any useful solutions that would fix my build script. The closest to a solution was this. But deleting project.assets.json before each msbuild did not help. Apparently there is a problem with restoring the NuGet packages for the different versions of .NET. Can you please suggest a solution.