首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >生成错误时,"SetEnv“任务无法从程序集Microsoft.Build.CppTasks.Common加载。

生成错误时,"SetEnv“任务无法从程序集Microsoft.Build.CppTasks.Common加载。
EN

Stack Overflow用户
提问于 2022-06-27 19:38:25
回答 1查看 112关注 0票数 0

在我的win10命令提示符计算机上有msbuildVersion14.0.25420.1,如果我试图用以下命令构建一个visual studio项目文件:

代码语言:javascript
运行
复制
 msbuild .\folder1\WxsGenerators.sln

我犯了个错误

代码语言:javascript
运行
复制
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文件,我在这里发现了一个类似的错误:

错误MSB4062:无法从程序集加载"SetEnv“任务

在接受的答案中,我试图运行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错误?谢谢

EN

回答 1

Stack Overflow用户

发布于 2022-06-28 02:51:07

根据您的描述,您可以找到解决方案,但不知道如何在您的porject中绑定重定向msbuild程序集。我可以给你一些关于怎么做的建议。您可以在项目文件夹中创建一个app.config来绑定重定向,例如:

代码语言:javascript
运行
复制
<?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中。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72777506

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档