locked
Asp.Net Core 2.2 with C# 8 RRS feed

  • Question

  • User718448626 posted

    Hi,

    I would like to know if it is possible to compile a project with Asp.net Core 2.2 with C# 8 in Visual Studio 2017 ?   My project csproj below does not compile and I have core 3.1 sdk installed.

    <Project Sdk="Microsoft.NET.Sdk.Web">

    <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <LangVersion>8.0</LangVersion>
    <Nullable>enable</Nullable>
    <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
    </PropertyGroup>

    <!--  -->

    </Project>

    Sunday, December 15, 2019 2:40 AM

All replies

  • User-782232518 posted

    Microsoft made it very clear that .NET Core 3.x requires VS 2019 16.4 and above, https://docs.microsoft.com/en-us/dotnet/core/whats-new/dotnet-core-3-1 VS2017 won't work.

    Sunday, December 15, 2019 3:07 AM
  • User-474980206 posted

    no.

    C# 8 requires .net core 3.1 runtime or later to run the assemblies it produces.  C# 7.3 is the most current version that will support core 2.2. With C# 8.0 and beyond, the compiler version will be tied to a minimum runtime version. This allows the compiler changes to have matching runtime changes.

    note: As core 2.2 is only supported for a couple more weeks (ends 12/23/2019), you should fall back to 2.1 (supported to 8/21/2021) or upgrade to 3.1

     

    Sunday, December 15, 2019 4:11 AM
  • User-704723795 posted

    Are you trying to compile C# 8 to 2.2 assemblies, or are you trying to compile older code to 3.1 assemblies? 

    Sunday, December 15, 2019 10:32 PM
  • User718448626 posted

    No, I am compiling a Web API ASP.net Core 2.2.    The main reason that I cannot move to 3.0 or 3.1 is due to Odata still not supporting 3.1

    Monday, December 16, 2019 12:30 AM
  • User-854763662 posted

    Hi Albertk89 ,

    I would like to know if it is possible to compile a project with Asp.net Core 2.2 with C# 8 in Visual Studio 2017 ?

    No , the latest C# compiler determines a default language version based on your project's target framework or frameworks. C# language version default in .Net Core 3.x is C#8.0 , and in .Net Core 2.x is C# 7.3.

    You could refer to the C# language versioning Microsoft doc.

    Best Regards ,

    Sherry

    Monday, December 16, 2019 9:11 AM
  • User-474980206 posted

    As I stated, C# 8 requires a 3.1 runtime. Also as you can not move to 3.1, you should fall back to 2.1 as 2.2 support ends this month.

    Monday, December 16, 2019 3:18 PM
  • User-782232518 posted

    The main reason that I cannot move to 3.0 or 3.1 is due to Odata still not supporting 3.1

    That can be an invalid reason. Anything that works for .NET Core 2.x should work for .NET Core 3.x (unless unfortunately blocked by breaking changes). I don't recall .NET Core 3.x has OData related bugs.

    Friday, December 20, 2019 3:05 AM
  • User-474980206 posted

    follow this thread for core 3.1 support in odata:

       https://github.com/OData/WebApi/issues/1748

    it appears the daily build from 3 days ago may work.

    Friday, December 20, 2019 8:30 PM