Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not load file or assembly 'Microsoft.Build.Framework, Version=15.1.0.0

I've installed a new package on an existing project.enter image description here

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?

like image 930
Prosy Arceno Avatar asked Oct 14 '25 08:10

Prosy Arceno


2 Answers

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.

like image 198
Prosy Arceno Avatar answered Oct 17 '25 17:10

Prosy Arceno


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.

like image 22
Jeremy Thompson Avatar answered Oct 17 '25 17:10

Jeremy Thompson