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

时间:2017-04-06 14:29:26

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

我在项目中使用了一些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

2 个答案:

答案 0 :(得分:29)

您需要在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

答案 1 :(得分:2)

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

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