【问题标题】:error MSB4216: Could not run the "GenerateResource" task because MSBuild could not create or connect to a task错误 MSB4216:无法运行“GenerateResource”任务,因为 MSBuild 无法创建或连接到任务
【发布时间】:2019-03-04 16:25:55
【问题描述】:

请注意,我可以在 Visual Studio Professional 2017 中构建此项目:https://github.com/briannoyes/WPFMVVM-StarterCode

但是当我尝试在 Team City 2019.1 中运行构建时,它给了我这个错误:

C:\Program Files\dotnet\sdk\2.0.0\Microsoft.Common.CurrentVersion.targets(2924,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 "x86".

然后我找到了这个链接:

'dotnet build' error after migrating dotnetcore project to 1.0.4

从那里我按照评论中的建议将此添加到项目中:

<Prefer32Bit>false</Prefer32Bit>

但现在我收到此错误:

构建脚本报告的问题 (1) Customers\AddEditCustomerView.xaml.cs(25,13):错误 CS0103:名称 当前上下文中不存在“InitializeComponent” Customers\CustomerListView.xaml.cs(25,13):错误 CS0103:名称 当前上下文中不存在“InitializeComponent” OrderPrep\OrderPrepView.xaml.cs(25,13):错误 CS0103:名称 当前上下文中不存在“InitializeComponent” Orders\OrderView.xaml.cs(25,13):错误 CS0103:名称 当前上下文中不存在“InitializeComponent” MainWindow.xaml.cs(25,13):错误 CS0103:名称 当前上下文 CSC 中不存在“InitializeComponent”: 错误 CS5001:程序不包含适合的静态“主要”方法 对于一个入口点··· 构建失败情况 (1) 进程退出 带代码 1

这是我在构建步骤中的设置:

这是完整的构建日志:

https://pastebin.com/1JdhKWPf

有人有什么建议吗?

【问题讨论】:

  • 嗨。您已经发布了第 2 步设置的照片,但根据日志,第 4 步失败了。你说你可以在 Visual Studio 中构建项目,但你可以在自己的机器上通过命令行构建它吗?
  • 我可以在命令行上构建,使用这个命令没有错误:msbuild ZzaDesktop.sln
  • @Nanhydrin,感谢您的提示。我禁用了构建步骤 4,它现在可以工作了。请发布为答案,我将标记为解决方案。
  • 我不觉得我已经赢得了那个,我只是把你引向了正确的方向:) 你应该自己回答并接受你的回答,这样你就可以说出为什么它是正确的解决方案.

标签: c# teamcity


【解决方案1】:

请注意,最新的 TeamCity 默认支持 .NET Core,所以它自动添加了这一步:

但我真正需要的唯一构建步骤是我的问题中给出的第 2 步有效。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-04-26
    • 2012-03-19
    • 2016-02-23
    • 2022-12-11
    • 1970-01-01
    • 1970-01-01
    • 2017-02-16
    相关资源
    最近更新 更多