How to upgrade msbuild to C# 6?

前端 未结 3 1155
失恋的感觉
失恋的感觉 2020-12-02 12:56

I want to use C# 6 in my project (null propagation, other features).

I\'ve installed VS 2015 on my PC and it works brilliantly and builds test code like



        
3条回答
  •  难免孤独
    2020-12-02 13:31

    Make sure you call:

    C:\Program Files (x86)\MSBuild\14.0\Bin\MsBuild.exe
    

    That's the version of MsBuild that ships with Visual Studio 2015 and calls the C# compiler that understands this. You can get this version of MsBuild on your system by installing any edition of Visual Studio 2015 or by installing the stand-alone Microsoft Build Tools 2015.

    Adding a reference to the following NuGet package will also force use of the new compiler:

    Install-Package Microsoft.Net.Compilers
    

    Please note Install-Package will pick the latest available version which may not be the one you are looking for. Before you install, please check the release notes and dependencies to resolve the underlying issue with the version being dealt with, which in this case, was more specific to VS 2015.

    So for Visual Studio 2015:

    Install-Package Microsoft.Net.Compilers -Version 1.0.0
    

提交回复
热议问题