.net - 无法运行 "GenerateResource"任务,因为 MSBuild 无法创建或连接到运行时为 "CLR4"且体系结构为 "x64"的任务主机

标签 .net visual-studio msbuild .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
我怎样才能解决这个问题 ?
谢谢你。

最佳答案

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

<PropertyGroup> 

<GenerateResourceMSBuildArchitecture>CurrentArchitecture</GenerateResourceMSBuildArchitecture>
<GenerateResourceMSBuildRuntime>CurrentRuntime</GenerateResourceMSBuildRuntime>
    
</PropertyGroup>
2) 添加一个名为 DisableOutOfProcTaskHost 的系统环境变量并将其值设置为 true .
套装DISABLEOUTOFPROCTASKHOST1 .
3) 由于您的 VS2017 太旧了,我建议你更新你的 VS2017 到最新版本,以防有一些修复。或 repair vs .
还有 ,请确保您已安装工作负载 .Net Core跨平台开发在 vs 安装程序中。
enter image description here
4) 关闭VS,删除.vs解决方案文件夹下的隐藏文件夹,binobj文件夹,然后重新启动您的 VS 以再次测试。 除了 ,您可以将目标框架版本更改为 net framework 4.6.1配置Any CPU .

关于.net - 无法运行 "GenerateResource"任务,因为 MSBuild 无法创建或连接到运行时为 "CLR4"且体系结构为 "x64"的任务主机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64295288/

相关文章:

c# - .NET 代码中的漂亮格式 sql,性能?

c# - Process.Start 功能

c# - Enumerable.Single 的错误执行?

c++ - VisualStudio - 非常长的监视变量的别名

c++ - Visual Studio 2010 专业版 : Cannot find include file "new.h"

jenkins - 使用 Jenkins 发布 ASP.NET CORE 项目的配置

.net - youtube - 视频上传失败 - 无法转换文件 - 视频编码错误?

c# - 为什么我的 C# 中的 SQL 代码不起作用?

c# - WPF Clickonce 使用 Microsoft.Net.Sdk 发布

c++ - 即使启用了 Visual Studio 14 2015 Win64 工具链,也使用 32 位工具链进行编译