简体   繁体   中英

What does DisableOutOfProcTaskHost do?

I recently ran into a problem with building a WPF application with the following error:

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". 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.

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. Object does not match target type.

What helped me was to set a system variable DISABLEOUTOFPROCTASKHOST to 1 . This solution is googled and I could not find an explanation on what is happening and why DISABLEOUTOFPROCTASKHOST helped me.

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

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.

The solution is to add these xml node in your xxx.csproj file:

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

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. Fortunately My problem was solved.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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