【问题标题】:How to build .csproj with C# 7 code from command line (msbuild)如何从命令行使用 C# 7 代码构建 .csproj (msbuild)
【发布时间】:2017-09-01 15:47:51
【问题描述】:

我在我的项目中使用了一些 C# 7 功能:

static void Main(string[] args)
{
}

public byte ContainerVersion
{
    get => 1;
    private set => throw new NotImplementedException();
}

它在 Visual Studio 2017 中构建良好,但在使用旧的 msbuild (v14.0 C:\Program Files (x86)\MSBuild\14.0\Bin\msbuid.exe consoleApplication.csproj.) 时我的 CI 代理出现错误:

error CS1513: } expected.

【问题讨论】:

    标签: c# msbuild visual-studio-2017 c#-7.0


    【解决方案1】:

    您需要在 CI 代理上安装 msbuild-2015

    https://www.visualstudio.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=15

    msbuild 的默认安装目录为: C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe

    【讨论】:

    • MSBuild 15 与 VS 一起安装。它将位于 %VSINSTALLDIR%\MSBuild\15.0\Bin\MSBuild.exe 下。 Build Tools SKU 适用于您不想安装 VS 的 CI 代理。这两种情况都值得注意。
    • 吉米,你是对的。但是,我们有一些在 CI 代理上使用 msbuild 手册的特殊任务。
    • 即使在服务器 c:\program files (x86)\msbuild\15.0 上安装了独立的 2017 构建工具后,除了 \FileTracker 文件夹之外什么都没有,没有 msbuild.exe 或任何东西。在我尝试这个之前,我确实在服务器上安装了 VS2017,但似乎有些东西搞砸了,有什么想法吗?
    • 你知道吗,为什么 .NET Framework 自带的msbuild.exe 无法构建 C# 7 功能?
    【解决方案2】:

    安装Visual Studio 2017 Community Edition后,我机器上msbuild.exe的路径是:

    C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-06-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-12
      • 1970-01-01
      • 2023-03-13
      • 1970-01-01
      相关资源
      最近更新 更多