【问题标题】:TeamCity fails to build projects using C# 7TeamCity 无法使用 C# 7 构建项目
【发布时间】:2017-10-08 09:55:54
【问题描述】:

当我在最新的代码更新中添加新的输出变量语法时,TeamCity 抛出错误:

if (Enum.TryParse(input, out MyProject.ClassificationType classification))
{
    result.Classification = classification;
}

TeamCity 抛出此错误:

[Csc] MyProject\MyCode.cs(125, 111): error CS1003: Syntax error, ',' expected

代码在 Visual Studio 中构建和运行良好。

【问题讨论】:

    标签: c# teamcity c#-7.0


    【解决方案1】:

    TeamCity Agent 机器上的 MSBuild 已过时,无法使用 Microsoft Build Tools 2015。

    我可以通过下载并安装新的 Build Tools for Visual Studio 2017 来解决此问题:

    https://www.visualstudio.com/downloads/ -> Other Tools and Frameworks -> Build Tools for Visual Studio 2017 -> Download

    或者通过这里绕过垃圾邮件:https://www.visualstudio.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=15

    更新 TeamCity 的构建步骤以使用 MSBuild 15 或 Visual Studio 2017 进行构建。

    【讨论】:

    • MSBuild 15 和 Visual Studio 2017 有什么区别?
    • “MSBuild”和“Visual Studio (.sln)”在您设置构建步骤时是两种不同的运行器类型。
    • 抱歉笨,但是我对配置TC了解不多。我被要求调查将 C#7 加入其中,但不确定您对不同跑步者类型的意思。请问你能解释一下吗?谢谢
    【解决方案2】:

    按照 Kcoder 的建议安装 Visual Studio 2017 的构建工具, 之后调整 Team City 中的构建步骤(示例):

    如果您使用 MSBuild 作为构建步骤,您可以调整类似的设置。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-25
      • 2015-12-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多