简体   繁体   English

DisableOutOfProcTaskHost 有什么作用?

[英]What does DisableOutOfProcTaskHost do?

I recently ran into a problem with building a WPF application with the following error:我最近在构建 WPF 应用程序时遇到问题,出现以下错误:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(3036,5): error MSB4216: Could not run the "GenerateResource" task because MSBuild could not create or connect to a task host with runtime "CLR4" and architecture "x64". C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(3036,5):错误 MSB4216:无法运行“GenerateResource”任务,因为 MSBuild 可以不创建或连接到具有运行时“CLR4”和体系结构“x64”的任务主机。 Please ensure that (1) the requested runtime and/or architecture are available on the machine, and (2) that the required executable "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\amd64\MSBuild.exe" exists and can be run.请确保 (1) 请求的运行时和/或体系结构在计算机上可用,并且 (2) 所需的可执行文件“C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin \amd64\MSBuild.exe" 存在并且可以运行。

C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(3058,7): error MSB4028: The "GenerateResource" task's outputs could not be retrieved from the "FilesWritten" parameter. C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(3058,7):错误 MSB4028:无法从中检索“GenerateResource”任务的输出“FilesWritten”参数。 Object does not match target type. Object 与目标类型不匹配。

What helped me was to set a system variable DISABLEOUTOFPROCTASKHOST to 1 .对我有帮助的是将系统变量DISABLEOUTOFPROCTASKHOST设置为1 This solution is googled and I could not find an explanation on what is happening and why DISABLEOUTOFPROCTASKHOST helped me.这个解决方案是用谷歌搜索的,我找不到关于正在发生的事情以及为什么DISABLEOUTOFPROCTASKHOST帮助我的解释。

Can anyone explain to me what was the cause of the error and why the variable helped me?任何人都可以向我解释错误的原因是什么以及为什么变量对我有帮助吗?

In your side , it seems that you have compiled a resource with a different architecture than the host MSBuild instance is.在你这边,你似乎编译了一个与主机 MSBuild 实例不同架构的资源。 It may be caused by the problem with different versions of your project resource files or using different versions of the code that need to launch an additional process of a differeet version of MSBuild ( arm64\msbuild.exe ) using a different CLR .这可能是由于您的项目资源文件版本不同或使用不同版本的代码需要使用不同的CLR启动不同版本的MSBuild ( arm64\msbuild.exe ) 的附加进程引起的。

So the approach is that you should let MSBuild always follow the current file build version, that is, it can automatically switch between different versions of the build mechanism under the same MSBuild build process.所以做法是让MSBuild始终跟随当前的文件构建版本,即可以在同一个MSBuild构建过程下自动切换不同版本的构建机制。

The solution is to add these xml node in your xxx.csproj file:解决方案是在您的xxx.csproj文件中添加这些 xml 节点:

<PropertyGroup>   
     <GenerateResourceMSBuildArchitecture>CurrentArchitecture</GenerateResourceMSBuildArchitecture>
     <GenerateResourceMSBuildRuntime>CurrentRuntime</GenerateResourceMSBuildRuntime>
</PropertyGroup>

Or add environment variable DISABLEOUTOFPROCTASKHOST to 1 .(let it switch between different versions of build mechanism under the same MSBuild.exe build process)或者将环境变量DISABLEOUTOFPROCTASKHOST添加到1 。(让它在相同的MSBuild.exe构建过程下在不同版本的构建机制之间切换)

I had the same Error.我有同样的错误。 but By Repairing Visual Studio 2019, close VS, delete.vs hidden folder (under solution folder),bin and obj folder then restart your VS.但通过修复 Visual Studio 2019,关闭 VS,删除 .vs 隐藏文件夹(在解决方案文件夹下)、bin 和 obj 文件夹,然后重新启动 VS。 Fortunately My problem was solved.幸好我的问题解决了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM