在我的win10命令提示符计算机上有msbuildVersion14.0.25420.1,如果我试图用以下命令构建一个visual studio项目文件:
msbuild .\folder1\WxsGenerators.sln
我犯了个错误
BUILD FAILED
D:\Dev\Views\YY261307_main_sv\microsoft\MSBuild\Microsoft.Cpp\v4.0\Microsoft.Cpp.targets(40,5): error MSB4062: The "SetEnv" task could not be loaded from the assembly Microso
ft.Build.CppTasks.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=xxx. Could not load file or assembly 'Microsoft.Build.CppTasks.Common, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=xxx' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, th
at the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [D:\path\TomtecWxs.vcxproj]
在我的机器上,我安装了visual studio 2015和visual studio 2019。我需要弄清楚如何修复这个错误并构建.sln文件,我在这里发现了一个类似的错误:
在接受的答案中,我试图运行npm命令,但无法运行,另一个解决方案create .config file in the same dir as your exe (if you don't have it already) containing binding redirection of msbuild assemblies
我不知道如何运行。
有什么方法可以让我更好地理解/修复这个"SetEnv" task could not be loaded from the assembly Microso ft.Build.CppTasks.Common
错误?谢谢
发布于 2022-06-28 02:51:07
根据您的描述,您可以找到解决方案,但不知道如何在您的porject中绑定重定向msbuild程序集。我可以给你一些关于怎么做的建议。您可以在项目文件夹中创建一个app.config来绑定重定向,例如:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/>
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Build.Utilities.Core" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" />
<bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="15.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Build.Framework" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" />
<bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="15.1.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
您可以查看C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe.config
并将必要的块复制到项目文件夹中的app.config中。
https://stackoverflow.com/questions/72777506
复制相似问题