无法运行“GenerateResource"任务,因为 MSBuild 无法创建或连接到具有运行时“CLR4"的任务主机.和架构“x64" [英] Could not run the "GenerateResource" task because MSBuild could not create or connect to a task host with runtime "CLR4" and architecture "x64"
问题描述
我使用的是 Visual Studio 2017 企业版 15.7.1 和 .NET Framework 4.5.
我刚刚安装了 Windows 10 更新版本 10.0.18363 build 18363.
我可以在同一个解决方案中构建其他项目,但对于这个项目,我在构建时遇到此错误
2>C:Program Files (x86)Microsoft Visual Studio2017ProfessionalMSBuild15.0BinMicrosoft.Common.CurrentVersion.targets(3045,5):错误 MSB4216:无法运行GenerateResource"任务,因为 MSBuild 无法创建或连接到具有运行时CLR4"的任务主机.和架构x64".请确保 (1) 请求的运行时和/或架构在机器上可用,以及 (2) 所需的可执行文件C:Program Files (x86)Microsoft Visual Studio2017ProfessionalMSBuild15.0Binamd64MSBuild.exe"存在并且可以运行.错误 MSB4028 GenerateResource"无法从FilesWritten"中检索任务的输出.范围.对象与目标类型不匹配.我的项目名称 C:Program Files (x86)Microsoft Visual Studio2017ProfessionalMSBuild15.0BinMicrosoft.Common.CurrentVersion.targets 3066
我该如何解决这个问题?谢谢.
试试这些:
1) 在您的 xxx.csproj
文件中添加这些 xml 节点:
<GenerateResourceMSBuildArchitecture>CurrentArchitecture</GenerateResourceMSBuildArchitecture><GenerateResourceMSBuildRuntime>CurrentRuntime</GenerateResourceMSBuildRuntime></PropertyGroup>
2) 添加名为 DisableOutOfProcTaskHost
的系统环境变量并将其值设置为 true
.
或将DISABLEOUTOFPROCTASKHOST
设置为1
.
3) 由于您的 VS2017 太旧了,我建议您将 VS2017 更新到最新版本,以防有一些修复.或者
4)关闭VS,删除解决方案文件夹下的.vs
隐藏文件夹,bin
和obj
文件夹然后重新启动您的 VS 以再次测试.此外,您可以将目标框架版本更改为net framework 4.6.1
,将配置更改为Any CPU
.
I am using Visual Studio 2017 Enterprise version 15.7.1 and .NET Framework 4.5.
I just installed Windows 10 Update version 10.0.18363 build 18363.
I can build other projects in the same Solution, but for this one project, I am getting this error while building
2>C:Program Files (x86)Microsoft Visual Studio2017ProfessionalMSBuild15.0BinMicrosoft.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 Studio2017ProfessionalMSBuild15.0Binamd64MSBuild.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 Studio2017ProfessionalMSBuild15.0BinMicrosoft.Common.CurrentVersion.targets 3066
How can I fix this ? Thank you.
Try these:
1) add these xml node in your xxx.csproj
file:
<PropertyGroup>
<GenerateResourceMSBuildArchitecture>CurrentArchitecture</GenerateResourceMSBuildArchitecture>
<GenerateResourceMSBuildRuntime>CurrentRuntime</GenerateResourceMSBuildRuntime>
</PropertyGroup>
2) add a system environment variable called DisableOutOfProcTaskHost
and set its value to true
.
Or set DISABLEOUTOFPROCTASKHOST
to 1
.
3) since your VS2017 is too old, I suggest you could update your VS2017 to the latest version in case there are some fixes. Or repair vs.
Also, make sure that you have installed the workload .Net Core cross-platform development in vs installer.
4) close VS, delete .vs
hidden folder under solution folder, bin
and obj
folder then restart your VS to test again. Besides, you can change your target framework version to net framework 4.6.1
and Configuration to Any CPU
.
这篇关于无法运行“GenerateResource"任务,因为 MSBuild 无法创建或连接到具有运行时“CLR4"的任务主机.和架构“x64"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!