9

I have few questions on the .NET Standard and the recently announced .NET Core 3.0 and ASP.NET Core 3.1

The previous versions of .NET Standard had the same major version as that of the .NET core being released, but for .NET Core 3.1 the compatible is .NET Standard 2.1.

enter image description here

  1. Is .NET Standard slowing going towards obsoletion or this is just a version number with no correlation to .NET Core release?
  2. Can we assume .NET Standard 2.1 will be compatible with ASP.NET Core 3.1 as well ?
  3. If we migrate existing web apps and MVC web API to asp.net core 3.1 then what happens to the existing .net standard class libraries that were used by web app ?

Do we change the target framework for our old .NET Standard class libraries from :

<TargetFramework>netstandard2.0</TargetFramework>

To

<TargetFramework>netstandard2.1</TargetFramework>

Or Change to

<TargetFramework>netcoreapp3.0</TargetFramework> 

and add a FrameworkReference to Microsoft.AspNetCore.App

ameya
  • 1,448
  • 1
  • 15
  • 31

1 Answers1

11
  1. The version number of .NET Standard does not move in step with .NET Core, any previous match-ups were coincidental. .NET Standard release at a slower cadence, however includes more APIs when it does move vs .NET Core, so it isn't going obsolete in that sense.

Aside - .NET Standard will be less relevant moving forward when .NET 5 comes out and unifies the platform, and now that multi-targeting works so well, it will still remain relevant for the following year and be relevant for dealing with API surfaces of older frameworks.

  1. ASP.NET Core 3.0 is compatible with .NET Standard 2.1, therefore ASP.NET Core 3.1 will be also be. (The phasing you use suggests you have the relationship backwards)

  2. You can continue to reference .NET Standard 2.0 libraries from frameworks that support it and higher, so you could still use it in ASP.NET Core 3.1 when it becomes available.

For your final question, it depends :)

If you are dealing with a non-web library, then netstandard2.1 would be suitable (not mandatory though, you can leave it at 2.0).

If you have an ASP.NET Core project, or related web library project, then you probably want to move to netcoreapp3.0.

For clarification on my last point, you won't find a better explanation than from Andrew Lock here: https://andrewlock.net/converting-a-netstandard-2-library-to-netcore-3/

The official guidance on upgrading can be found here

Stuart
  • 5,358
  • 19
  • 28
  • It's worth noting that your choice of .NET Standard 2.0 vs .NET Core 3.0 boils down to whether or not you need APIs introduced in .NET Core 3.0: things like `Span`, etc. If you don't need to take advantage of these, it's probably better to target .NET Standard 2.0 for wider compatibility. There's really no point in targeting .NET Standard 2.1, as nothing other than .NET Core 3+ supports it, and likely never will. – Chris Pratt Nov 25 '19 at 17:25
  • 1
    Agreed with you on the first part. It's "only" .NET Framework dropping support, mono and Xamarin are still good for 2.1 for example. – Stuart Nov 25 '19 at 18:28
  • @Stuart - wow, I didn't know that (dropped .NET Framework support). So I looked at https://dotnet.microsoft.com/platform/dotnet-standard, and I see what you are saying: when select ".NET Standard 2.0", it shows that ".NET Framework 4.6.1" and higher support that. Change the dropdown to ".NET Standard 2.1", and there are NO .NET Frameworks that support it! – ToolmakerSteve Sep 09 '20 at 03:24