msbuild错误,“ setenv”无法从汇编Microsoft.build.cpptasks.common加载任务

发布于 2025-02-10 20:06:18 字数 1498 浏览 2 评论 0 原文

如果我尝试使用此命令构建Visual Studio Project文件,我的Win10命令提示符上有MSBUILD版本14.0.25420.1,

 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命令但是无法做到,其他解决方案在与您的exe(如果还没有的话)中的同一dir中创建.config文件,该文件包含MSBUILD汇编的绑定重定向我不确定如何如何 我有

什么方法可以更好地理解 /修复此“ setEnv”任务无法从汇编microso ft.build.cpptasks.common < / code>错误中加载?谢谢

I have msbuild version 14.0.25420.1 on my win10 command prompt computer, If I try to build a visual studio project file with this command:

 msbuild .\folder1\WxsGenerators.sln

I get an error

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]

On my machine I have visual studio 2015 and visual studio 2019 installed. I need to figure out how to fix this error and build the .sln file, I've found a similar error posted here:

Error MSB4062: The "SetEnv" task could not be loaded from the assembly

In the accepted answer, I tried to run the npm commands but was unable to do so, the other solution create .config file in the same dir as your exe (if you don't have it already) containing binding redirection of msbuild assemblies I am not sure how to do

Is there any way I can understand better / fix this "SetEnv" task could not be loaded from the assembly Microso ft.Build.CppTasks.Common error? Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

杀手六號 2025-02-17 20:06:18

根据您的描述,您会发现

<?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 \ community \ msbuild \ current \ current \ current \ bin \ msbuild.exe.exe.exe 。

According to your description you find the solution but don’t know how to bind redirect msbuild assemblies in your porject.
I can give you some suggestions about how to do that.
You can create an app.config in your project folder to bind Redirects such as:

<?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>

You can look at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe.config and copy necessary blocks to your app.config in project folder.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文