2

We are in the process of migrating our applications from .NET core 3.1 to .NET 6. We have a few class libraries that we use in our .NET core applications and some of these libraries have a dependency over Microsoft.Extensions.* packages.

During this migration process I have noticed that most of the Microsoft.Extensions.* packages use netstandard2.0 as a target framework, so they are compatible with both .net core 3.1 and .net 6. In other words, it is possible to reference Microsoft.Extensions.* packages version 6.x from a .net core 3.1 application.

Is it safe to do so ? Should I expect possible runtime issues in doing so ?

From a semantic version point of view, I would expect Microsoft.Extensions.* packages version 6.x not to be compatible with .NET core 3.1 applications, but the choice of netstandard2.0 as a target framework seems to suggest a backward compatibility.

Does anyone know if these libraries have been designed with backward compatibility in mind ?

Enrico Massone
  • 6,464
  • 1
  • 28
  • 56
  • 1
    _"I would expect Microsoft.Extensions.* packages version 6.x not to be compatible with .NET core 3.1 applications"_ - I thought the same thing myself, but to my surprise all of the 6.x `Microsoft.Extensions.*` packages all work fine with older versions of .NET Core, even .NET Framework 4.8. – Dai Oct 21 '22 at 22:42
  • @Dai did you mange to find any official guideline in the Microsoft documentation or inside a Github issue ? – Enrico Massone Oct 21 '22 at 22:50
  • The search term you want is ".NET Platform Extensions": that refers to the `Microsoft.Extensions.*` packages and some no-longer-inbox `System.*` libraries too. As for support: I remember reading _something_ a few years ago, I'm trying to find it again now for you. ([Does this help?](https://stackoverflow.com/q/56354899/159145)) – Dai Oct 21 '22 at 22:53
  • 1
    UPDATE: Hmm, my google-fu has turned-up short. The best explanation I can give you is something along the lines of "[.NET Platform Extensions](https://learn.microsoft.com/en-us/dotnet/api/?view=dotnet-plat-ext-6.0) will work... until they won't." - so _regardless_ of the NuGet package's version number (and whether or not it's a bigger number than your .NET environment's version number) the only thing that really matters is the package's listed dependencies. As for how-long-they'll-support-older-.NET-versions... no idea! – Dai Oct 21 '22 at 22:59
  • 2
    6 hours later, I filed a doc bug: https://github.com/dotnet/docs/issues/31974 – Dai Oct 22 '22 at 05:28
  • @Dai thanks! Let's wait for some clarifications from the Microsoft side. – Enrico Massone Oct 22 '22 at 08:31

0 Answers0