无法加载文件或程序集 ‘Microsoft.Build.Framework,版本=15.1.0.0

huangapple go评论71阅读模式
英文:

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

问题

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?

英文:

I've installed a new package on an existing project.无法加载文件或程序集 ‘Microsoft.Build.Framework,版本=15.1.0.0

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?

答案1

得分: 2

Microsoft.Build.Locator 解决了我的问题。

> 为了确保你的应用程序中的程序化构建与在Visual Studio或MSBuild.exe中执行的构建相匹配,您可能需要加载与特定版本的Visual Studio一起安装的相同版本的MSBuild组件,并使用该版本Visual Studio中可用的SDK。或者,当您创建一个构建应用程序,该应用程序将在可能安装了各种不同版本的MSBuild、.NET和Visual Studio的机器上运行时,您可能还想要查找并使用一致的MSBuild版本。Microsoft.Build.Locator API简化了这个过程。

英文:

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.

答案2

得分: 1

去/Obj文件夹,备份project.assets.json文件。

编辑project.assets.json文件,删除引用v15.1.0.0的json块/段。

现在尝试安装v=17.5.0引用,Visual Studio不应混淆并加载旧版本。

如果失败,您可以尝试删除NuGet缓存,方法是在Visual Studio > 工具 > 包管理器 > 设置中点击"删除NuGet包"按钮,然后通过包管理器重新添加NuGet引用。

英文:

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.

huangapple
  • 本文由 发表于 2023年5月15日 13:59:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/76251230.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定