![](/img/trans.png)
[英]ERROR in C# API project after upgrading .NET framework from 4.0 to 4.6.1 in Visual Studio 2017
[英]WiX toolset build fails after upgrading from .net 4.0 to 4.6.1: Cannot load MSBuild wrapper?
因此,在将我的整个项目升级到 4.6.1 后,我在构建它时遇到了这个错误:
Failed to load MSBuild wrapper object: Could not load file or assembly 'Microsoft.Build, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
我也得到
The command ""C:\Program Files (x86)\WiX Toolset v3.10\Bin\heat.exe" project "C:\Project\Project.csproj" -projectname "Project" -pog Binaries -gg -sfrag -nologo -out "obj\\Release\Harvested XML\_Project.xml"" exited with code 5316. 86
这里的问题是程序集绑定日志查看器没有显示任何内容,所以我不知道 WiX 在哪里搜索 MSBuild 版本 12,或者它是否确实存在并且还有另一个潜在问题。
我检查了很多 SO 答案,也搜索了很多,但我找不到像这样的问题。 当然,我尝试了它们,但没有任何效果。
关于这个或为什么 fuslogvw 什么都没有显示的任何想法? 这对我有很大帮助
非常感谢!
更新:fuslogvw output:
*** Assembly Binder Log Entry (28/04/2016 @ 12:28:06 PM) ***
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable C:\Program Files (x86)\WiX Toolset v3.10\Bin\heat.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = Microsoft.Build, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
(Fully-specified)
LOG: Appbase = file:///C:/Program Files (x86)/WiX Toolset v3.10/Bin/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = heat.exe
Calling assembly : WixVSExtension.MSBuild12, Version=3.0.0.0, Culture=neutral, PublicKeyToken=ce35f76fcda82bad.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Program Files (x86)\WiX Toolset v3.10\Bin\heat.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Microsoft.Build, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/WiX Toolset v3.10/Bin/Microsoft.Build.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/WiX Toolset v3.10/Bin/Microsoft.Build/Microsoft.Build.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/WiX Toolset v3.10/Bin/Microsoft.Build.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/WiX Toolset v3.10/Bin/Microsoft.Build/Microsoft.Build.EXE.
LOG: All probing URLs attempted and failed.
我不知道为什么fuslogvw什么也没显示,它是否配置为记录绑定失败?
WiX使用标准方式加载程序集( https://github.com/wixtoolset/wix3/blob/develop/src/ext/VSExtension/wixext/VSProjectHarvester.cs#L1119 )
msbuildWrapperAssembly = Assembly.Load(String.Format(MSBuildWrapperAssemblyName, shortVersion, thisAssemblyName.Version, publicKeyToken));
包装器直接引用Microsoft.Build( https://github.com/wixtoolset/wix3/blob/develop/src/ext/VSExtension/wixext/WixVSExtension.MSBuild12/WixVSExtension.MSBuild12.csproj#L23 )。
<Reference Include="Microsoft.Build, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
有关热量如何决定加载哪个版本的MSBuild的说明,请参见问题4853 。
发生此错误的原因是HEAT正在查看.csproj文件的ToolsVersion并使用它来确定要加载的MSBuild.Tools程序集的版本。 将此从'12 .0'(或你有什么)更改为您使用的MSBuild版本可以解决此问题。
对于较旧的项目,如果需要特定版本的 MSBuild 工具,则可能会发生这种情况。
关闭 Visual Studio,然后
安装Microsoft Build Tools 2013 (v12.0),或
安装Microsoft.Build
错误中显示的 Microsoft Build Tools 版本
我的具体情况
Could not load file or assembly 'Microsoft.Build.Utilities.v12.0, Version=12.0.0.0...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.