无法运行"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"

查看:80
本文介绍了无法运行"GenerateResource"任务是因为MSBuild无法使用运行时"CLR4"创建或连接到任务主机.和架构"x64"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Visual Studio 2017企业版15.7.1和.NET Framework 4.5.

我刚刚安装了Windows 10更新版本10.0.18363内部版本18363.

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

  2> C:\ Program Files(x86)\ Microsoft Visual Studio \ 2017 \ Professional \ MSBuild \ 15.0 \ Bin \ Microsoft.Common.CurrentVersion.targets(3045,5):错误MSB4216:无法运行"GenerateResource"任务是因为MSBuild无法使用运行时"CLR4"创建或连接到任务主机.和架构"x64".请确保(1)该请求的运行时和/或体系结构在计算机上可用,以及(2)所需的可执行文件"C:\ Program Files(x86)\ Microsoft Visual Studio \ 2017 \ Professional \ MSBuild \ 15.0 \Bin \ amd64 \ MSBuild.exe"存在并且可以运行.错误MSB4028.无法从"FilesWritten"中检索任务的输出.范围.对象与目标类型不匹配.我的项目名称C:\ Program Files(x86)\ Microsoft Visual Studio \ 2017 \ Professional \ MSBuild \ 15.0 \ Bin \ Microsoft.Common.CurrentVersion.targets 3066 

我该如何解决?谢谢.

解决方案

尝试以下方法:

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

 < PropertyGroup>< GenerateResourceMSBuildArchitecture>当前架构</GenerateResourceMSBuildArchitecture>< GenerateResourceMSBuildRuntime>当前运行时间</GenerateResourceMSBuildRuntime></PropertyGroup> 

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

DISABLEOUTOFPROCTASKHOST 设置为 1 .

3),因为您的 VS2017 太旧,我建议您将 VS2017 更新到最新版本,以防万一..或

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

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 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

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆