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

12,783

Solution 1

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

Solution 2

Having installed Visual Studio 2017 Community Edition, the path to msbuild.exe on my machine is:

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

Share:
12,783

Related videos on Youtube

Dmitrii Zyrianov
Author by

Dmitrii Zyrianov

Updated on June 04, 2022

Comments

  • Dmitrii Zyrianov
    Dmitrii Zyrianov over 1 year

    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.

  • user2507101
    user2507101 over 6 years
    MSBuild 15 is installed with VS. It would be under %VSINSTALLDIR%\MSBuild\15.0\Bin\MSBuild.exe. The Build Tools SKU is intended for CI agents where you don't want to have VS installed. It's worth noting both cases.
  • Dmitrii Zyrianov
    Dmitrii Zyrianov over 6 years
    Jimmy, you are right. But, we have some special tasks that uses msbuild manual on CI agents.
  • Peter
    Peter over 6 years
    Even after installing the standalone 2017 build tools on a server c:\program files (x86)\msbuild\15.0 has nothing in it but a \FileTracker folder there is no msbuild.exe or anything. I did have VS2017 installed on the server before I tried this but seems like something is messed up, any ideas?
  • RBT
    RBT over 2 years
    Do you know, why the msbuild.exe which comes with .NET Framework is unable build C# 7 features?