无法运行“GenerateResource”任务,因为 MSBuild 无法创建或连接到具有运行时“CLR4”和体系结构“x64”的任务主机

fau*_*ong 5 .net msbuild visual-studio .net-4.5

我使用的是 Visual Studio 2017 企业版 15.7.1 和 .NET Framework 4.5。

我刚刚安装了 Windows 10 更新版本 10.0.18363 build 18363。

我可以在同一个解决方案中构建其​​他项目,但对于这个项目,我在构建时遇到此错误

2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(3045,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\2017\Professional\MSBuild\15.0\Bin\amd64\MSBuild.exe" exists and can be run.

Error   MSB4028 The "GenerateResource" task's outputs could not be retrieved from the "FilesWritten" parameter. 
Object does not match target type.  my-project-name C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets   3066
Run Code Online (Sandbox Code Playgroud)

我怎样才能解决这个问题 ?谢谢你。

Mr *_*ian 6

试试这些:

1)在您的xxx.csproj文件中添加这些 xml 节点:

<PropertyGroup> 

<GenerateResourceMSBuildArchitecture>CurrentArchitecture</GenerateResourceMSBuildArchitecture>
<GenerateResourceMSBuildRuntime>CurrentRuntime</GenerateResourceMSBuildRuntime>
    
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)

2)添加一个名为的系统环境变量DisableOutOfProcTaskHost并将其值设置为true.

设置DISABLEOUTOFPROCTASKHOST1

3)由于您的VS2017太旧,我建议您将VS2017更新到最新版本,以防有一些修复。或修复 vs

另外,请确保您已在 vs 安装程序中安装了工作负载.Net Core 跨平台开发

在此处输入图片说明

4)关闭VS,删除.vs隐藏文件夹的解决方案文件夹下,bin并且obj文件夹,然后再次重新启动VS测试。此外,您可以将目标框架版本更改为net framework 4.6.1并将配置更改为Any CPU.