【问题标题】:Could not run the "GenerateResource" task because MSBuild could not create or connect to a task host with runtime "CLR4" and architecture "x64"无法运行“GenerateResource”任务,因为 MSBuild 无法创建或连接到运行时“CLR4”和体系结构“x64”的任务主机
【发布时间】:2020-10-10 15:47:21
【问题描述】:

我正在使用 Visual Studio 2017 Enterprise 版本 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

我该如何解决这个问题? 谢谢。

【问题讨论】:

    标签: .net visual-studio msbuild .net-4.5


    【解决方案1】:

    试试这些:

    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隐藏文件夹,binobj文件夹然后重启你的VS再次测试。 此外,您可以将目标框架版本更改为net framework 4.6.1,将配置更改为Any CPU

    【讨论】:

    • 耶!我完成了所有 4 个步骤,现在我可以成功编译这个项目。我现在有 VS 2017 版本 15.9.27。非常感谢您的帮助!!!
    【解决方案2】:

    我遇到了同样的错误(在 16.9.3 版中),但通过修复 Visual Studio 2019、更新 Windows 10 的最新版本、关闭 VS、删除 .vs 隐藏文件夹(在解决方案文件夹下)、bin 和 obj 文件夹,然后重新启动你的VS 。幸好我的问题解决了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-04-26
      • 2017-02-23
      • 2017-06-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多