简体   繁体   中英

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

I use some C# 7 features in my project:

static void Main(string[] args)
{
}

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

and it builds fine in visual studio 2017, but I get an error on my CI agent when using old msbuild ( v14.0 C:\\Program Files (x86)\\MSBuild\\14.0\\Bin\\msbuid.exe consoleApplication.csproj. ):

error CS1513: } expected .

You'll need to install msbuild-2015 on your CI agent.

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

The default install directory for msbuild will be: C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\MSBuild\\15.0\\Bin\\MSBuild.exe

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM