I've installed a new package on an existing project.
The problem is it's detecting a different version of the Microsoft.Build.Framework
. I got Version=17.5.0
for both Microsoft.Build
and Microsoft.Build.Framework
but it's seeing Version=15.1.0.0
.
I have the updated version of NuGet (Version 6.5.0) which is compatible with my Visual Studio (Version 17.5.5) which according to this answer should fix it.
I've also restarted Visual Studio and tried again, which should also fix it according to this answer.
Is there something more going on under the hood here?
Microsoft.Build.Locator solved my issue.
To ensure that programmatic builds from your application match builds done within Visual Studio or MSBuild.exe, you might need to load the same version of the MSBuild assemblies that were installed with a specific version of Visual Studio and use the same SDKs that are available within that version of Visual Studio. Or, when you're creating a build application that will be run on machines that might have various installed versions of MSBuild, .NET, and Visual Studio, you might also want to find and use a consistent version of MSBuild. The Microsoft.Build.Locator API streamlines this process.
Go to the /Obj folder and take a backup copy of your project.assets.json file.
Edit the project.assets.json file removing the json chunks/segments that refer to the v15.1.0.0.
Now try to install the v=17.5.0 reference and Visual Studio shouldn't get confused and load an old version.
If that fails you might want to delete your NuGet Cache using Visual Studio > Tools > Package Manager > Settings > click the Delete NuGet Packages button and then re-add the NuGet references via the Package Manager.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With