如何从命令行 (msbuild) 使用 C# 7 代码构建 .csproj

How to build .csproj with C# 7 code from command line (msbuild)

我在我的项目中使用了一些 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.0\Bin\msbuid.exe consoleApplication.csproj.) 时我的 CI 代理出现错误:

error CS1513: } expected.

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

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

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

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

C:\Program Files (x86)\Microsoft Visual Studio17\Community\MSBuild.0\Bin\MSBuild.exe