How can I use C# 8 with Visual Studio 2017?

后端 未结 5 1980
你的背包
你的背包 2020-12-05 09:38

I\'d like to use C# 8.0 (especially ranges and non-nullable reference types) in Visual Studio 2017. Is it possible?

5条回答
  •  情书的邮戳
    2020-12-05 10:20

    You can Use Microsoft.Net.Compilers.Toolset instead of Microsoft.Net.Compilers in vs2017

    This package is intended as a replacement for Microsoft.Net.Compilers (which is a Windows-only package) and Microsoft.NETCore.Compilers. Those packages are now deprecated and will be deleted in the future.

    The package requires MSBuild 15.0 and either .NET Destkop 4.7.2 or .NET Core 2.1

    The package versions:

    The package version map the capability of c# 8 support compared to vs2019.

    • Version 3.0 includes a preview of C# 8.0 (Visual Studio 2019 version 16.0), but 2.11 was used for preview1.
    • Version 3.1 includes a preview of C# 8.0 (Visual Studio 2019 version 16.1)
    • Version 3.2 includes a preview of C# 8.0 (Visual Studio 2019 version 16.2)
    • Version 3.3 includes C# 8.0 (Visual Studio 2019 version 16.3, .NET Core 3.0)

    How to use

    Add these lines to the .csproj

     
         //....
        8.0    
        enable 
      
    
       
        
      
    

提交回复
热议问题