问题描述
我正在使用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):
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)将这些xml节点添加到您的xxx.csproj
文件中:
<PropertyGroup>
<GenerateResourceMSBuildArchitecture>CurrentArchitecture</GenerateResourceMSBuildArchitecture>
<GenerateResourceMSBuildRuntime>CurrentRuntime</GenerateResourceMSBuildRuntime>
</PropertyGroup>
2)添加一个名为DisableOutOfProcTaskHost
的系统环境变量,并将其值设置为true
。
或将DISABLEOUTOFPROCTASKHOST
设置为1
。
3),因为您的 VS2017 太旧了,建议您将 VS2017 更新到最新版本,以防出现某些问题。 。或repair vs。
也,请确保已在vs安装程序中安装了 .Net Core跨平台开发工作负载。
4)关闭VS,删除解决方案文件夹.vs
和bin
文件夹下的obj
隐藏文件夹,然后重新启动VS以再次进行测试。 此外,您可以将目标框架版本更改为net framework 4.6.1
,将配置更改为Any CPU
。
我遇到了同样的错误(版本 16.9.3),但是通过修复 Visual Studio 2019、更新最新版本的 Windows 10、关闭 VS、删除 .vs 隐藏文件夹(在解决方案文件夹下)、bin 和 obj 文件夹然后重新启动你的VS 。幸运的是我的问题解决了。