我使用的是 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
.或 套装
DISABLEOUTOFPROCTASKHOST
至 1
.3) 由于您的 VS2017 太旧了,我建议你更新你的 VS2017 到最新版本,以防有一些修复。或 repair vs .
还有 ,请确保您已安装工作负载 .Net Core跨平台开发在 vs 安装程序中。
4) 关闭VS,删除
.vs
解决方案文件夹下的隐藏文件夹,bin
和 obj
文件夹,然后重新启动您的 VS 以再次测试。 除了 ,您可以将目标框架版本更改为 net framework 4.6.1
和 配置至 Any CPU
.
关于.net - 无法运行 "GenerateResource"任务,因为 MSBuild 无法创建或连接到运行时为 "CLR4"且体系结构为 "x64"的任务主机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64295288/