Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET Standard and .NET Core 3.x or ASP.NET Core 3.x

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

like image 946
ameya Avatar asked Feb 04 '23 16:02

ameya


1 Answers

  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

like image 62
Stuart Avatar answered Feb 13 '23 05:02

Stuart