MSBuild could not create or connect to a task host with runtime "CLR2" and architecture "x86".

vs2010 and vs2012 are installed on target machine.

Build c# project using vs2010, following error occurred:

ERROR message :

error MSB4216: Could not run the "GenerateResource" task because MSBuild could not create or connect to a task host with runtime "CLR2" and architecture "x86".  Please ensure that (1) the requested runtime and/or architecture are available on the machine, and (2) that the required executable "C:Program FilesMicrosoft SDKsWindowsv8.0AinNETFX 4.0 ToolsMSBuildTaskHost.exe" exists and can be run.

Solution:

Set environment variables:

DisableOutOfProcTaskHost=true

____________________

Following solution is provided by  Forrest Guo

Following content is only used for knowledge sharing. ^^

This is a known issue which supposed to be fixed in later release. The MSBuildTaskHost.exe is introduced by Visual Studio 2012 but not the Windows SDK.  This is a new feature in VS 2012 build system, out of process build.

You can disable this feature if VS 2012 is not used in building. Setting environment variable: DISABLEOUTOFPROCTASKHOST=1

Reference: Build is unable to find MSBuildTaskHost.exe 

原文地址:https://www.cnblogs.com/cindy-hu-23/p/3666397.html