Published on:Feb 22, 2022
Views: 4398
Number of votes: 12
Average rating:

Rolling out support for .NET 6

In September last year, we released the Optimizely DXP platform for the modern version of the Microsoft .NET platform - .NET 5 (formerly known as .NET Core). This release wave included CMS version 12 and Commerce version 14 as well as platform support in our DXP cloud service.

In November Microsoft released the new version of this modern track of .NET: .NET 6. We have of course also been getting questions about .NET 6 support in Optimizely products. And specifically, whether projects on older versions (CMS 11, Commerce 13) using .NET Framework 4.x should upgrade to .NET 5 or wait for .NET 6 (spoiler: No need to wait, but also the wait is soon over).

Backwards compatibility in .NET (Core)

To understand what to expect from upgrades to .NET 5 and 6 it helps to think about their origins: .NET 5 and 6 are iterations of .NET Core, with .NET 5 following .NET Core 3.1. You can use .NET Core libraries in .NET 5 applications as long as they are not affected by any of the breaking changes in .NET 5, which are relatively few from .NET Core 3.1.

The same goes for .NET 6, it has relatively few breaking changes from .NET 5 and can use .NET 5 (and .NET Core) libraries in the same way. For example, the Microsoft.Data.SqlClient package does not contain assemblies compiled for .NET 5 or 6, since its .NET Core 3.1 assembly runs without modification in .NET 5 and 6.

In contrast, the changes from .NET Framework 4.x to the modern .NET are more significant, but hardly any difference between going from 4.x to 5 and directly from 4.x to 6.

Preparing for .NET 6, prioritizing .NET 5

Even before we released our .NET 5 support, we did test upgrades of our core packages to the .NET 6 preview version. And we confirmed our expectation that there were no major changes required. Reassured by this, we focused our efforts on tooling to support upgrades of .NET Framework solutions (CMS 11 / Commerce 13), including the newly released preview of self-service migration tooling for our cloud platform, as well as continuing to convert additional packages and addons to .NET 5.

.NET 6 wave starts today!

Today we are also announcing the first wave of support for .NET 6. This consists of two pieces:

  • Version 12.4.0 of the CMS Core packages. Note that this is a minor version release, i.e. there are no breaking changes in our APIs. The package supports both .NET 5 and .NET 6 solutions through multi-targeting (including both .NET 5 and .NET 6 compiled assemblies).
  • DXP cloud service support for .NET 6 solutions. Similar to the software, the platform also supports both .NET 5 and .NET 6 applications, and will automatically choose the correct runtime for your deployment package.

There is a reason I call this the first wave, and I’ll be completely transparent: We haven’t updated (or otherwise verified compatibility) all Optimizely packages yet. We are updating more packages as dependencies become available. Quite a few are under way and confirmed to not have any incompatibilities (but some require updated dependencies e.g. on Microsoft packages). We will continue to release .NET 5/6 multi targeted packages for CMS UI, Commerce, Find and select other packages in the coming weeks.

Should I choose .NET 5 or .NET 6?

The CMS Core packages we release today are the only ones that we know are affected by a breaking change in .NET 6 and hence need a .NET 6 compiled assembly to run properly in all scenarios. As far as we know all other Optimizely packages that today support .NET 5 also support .NET 6 without changes other than dependencies.

Because of this, we chose to release the first packages now so that you, depending on what packages you use, can potentially get started with .NET 6. If you are using a specific Optimizely addon or even a 3rd party package that is only compiled for .NET 5 (or even .NET Core, and certainly .NET Standard) it will most likely run fine in .NET 6 already.

If are working on a project, new or an upgrade from .NET Framework, you can continue to target .NET 5. A later upgrade to .NET 6 is likely going to be minimal effort.

Using .NET 6 today

Or if you want to, you can target .NET 6 today. Depending on what packages you use it will be more or less tricky. This is a setup I used to run a CMS site in .NET 6 on DXP today:

<PackageReference Include="EPiServer.CMS" Version="12.3.1" />
<PackageReference Include="EPiServer.CloudPlatform.Cms" Version="1.0.3" />
<!-- Extra top level dependencies needed to force CMS 6 compatible version of CMS Core -->
<PackageReference Include="EPiServer.CMS.AspNetCore.HtmlHelpers" Version="12.4.0" />
<PackageReference Include="EPiServer.Hosting" Version="12.4.0" />
<!-- Extra top level dependencies needed until our CloudPlatform and AspnetIdentity packages are updated to declare .NET 6 dependencies -->
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.Extensions" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.0" /> 
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="6.0.0" />

As you can see a few extra explicit top level dependencies are required to force the right versions of everything. Fewer and fewer of these will be necessary as we release packages with updated dependencies. So waiting a few weeks will make this simpler.

Minimal API:s Limitation

[Added 2022-03-28]

Note that the new hosting API using `WebApplication` that was introduced together with MinimalAPIs in ASP.NET Core 6 is not supported at this time. This is due to the a change in setup order that comes with this model which causes some issues with the way the CMS Initialization Modules currently work. So for the time being you will be limited to using the standard hosting model that relies on a separate Startup class when building your CMS applications.

Related: Resolving dependency conflits

[Added 2022-03-30]

I also recommend reading this blog post on Resolving Nuget dependency conflicts in Project SDK (PackageReference) model.

Feb 22, 2022

Vincent
( By Vincent, 2/22/2022 11:17:12 PM)

Thanks for sharing this great news, Magnus! 

Sven-Erik Jonsson
( By Sven-Erik Jonsson, 3/25/2022 7:44:29 AM)

Having recently upgraded to .net6 on a Commerce solution my experience was that:

  • EPiServer.Framework.AspNetCore for .net5 is constrained on Microsoft.Extensions.DependencyInjection < 6.0.0, which causes issues with automatic dependency resolution leaving you jumping through hoops to get the packages to resolve cleanly. Optimizely should really consider removing or increasing that constraint.
  • EPiServer.CMS.Core (12.4.2) is dependent on SixLabors.ImageSharp >= 2.0.0 and implicitly ImageSharp.Web >= 2.0.0 (for blob storage and basic resizing). Just that ImageSharp.Web 2.0.0 isn't released yet and has to be added via SixLabors own nuget feed. I find it really strange that a core package has a hard dependency against a specific image processing solution.

Johan Petersson
( By Johan Petersson, 3/25/2022 8:36:58 AM)

We haven't release full support for .NET6 yet, only the CMS Core packages. Have you updated them explitly? For a smoother upgrade I would recommend waiting until our umbrella package, which also includes e.g. CMS UI, is updated to .NET6 as well.

Mari Jørgensen
( By Mari Jørgensen, 3/25/2022 2:45:10 PM)

@Johan, any ETA on the remaining packages?

Sven-Erik Jonsson
( By Sven-Erik Jonsson, 3/25/2022 3:28:37 PM)

Some clarifications:

  • I wrote that Microsoft.Extensions.DependencyInjection < 6.0.0 for .net5 causes an issue with dependency resolution when you upgrade to .net6, because not all of the packages have .net6 support yet and as you know, you probably have other dependencies in your project than just Optimizely nugets targeting a variety of supported platforms.
  • I also wrote that there was an implicit dependency on ImageSharp.Web since as you surely also know the site has to provide images to the public and sure, for arguments sake you could install another package along side it but you absolutely cannot run ImageSharp.Web < 2.0.0 with the current dependency set. This is one of Optimizelys own example sites: https://github.com/episerver/Foundation/blob/net5/src/Foundation/Foundation.csproj#L33.

Magnus Rahl
( By Magnus Rahl, 3/30/2022 12:36:13 PM)

@Mari CMS UI was released yesterday (as version 12.4.0). This unblocks a lot of other packages in the dependency chain. We have done some updates on several of those already, just waiting for the final version of CMS UI and getting them through regression testing. So hopefully we should see e.g. Commerce in a couple of weeks.

Scott Reed
( By Scott Reed, 4/22/2022 8:38:01 AM)

Is there any update on the commerce packages?

Magnus Rahl
( By Magnus Rahl, 4/28/2022 5:21:12 PM)

@Scott, Commerce is still in regression testing. So we are a bit behind where we thought we would be, but it is very close now.

Sven-Erik Jonsson
( By Sven-Erik Jonsson, 4/29/2022 6:37:53 AM)

  • "We will continue to release .NET 5/6 multi targeted packages for CMS UI, Commerce, Find and select other packages in the coming weeks."
  • "So hopefully we should see e.g. Commerce in a couple of weeks."

It is now over a month later, which is an order of magnitude greater than the quoted statements.
I would say that "So we are a bit behind..." is a gross understatement, especially as .NET 5 is nearing end of support.

Magnus Rahl
( By Magnus Rahl, 4/29/2022 11:35:34 AM)

@Sven-Erik. Thank you for your feedback. In the release cycle for .NET 6 we opted to release and communicate even though not everything is complete. On previous comparable events we've kept everything behind locks until we know we can do a coordinated release, and we didn't want to do that this time. With this of course comes uncertainty. But I can assure you teams are, and have been, working really hard to make this happen.

Scott Reed
( By Scott Reed, 5/13/2022 10:22:46 AM)

For anyone still interested looks like .NET 6 support came out today with 14.3.0 https://nuget.optimizely.com/package/?id=EPiServer.Commerce.Core&v=14.3.0

Sven-Erik Jonsson
( By Sven-Erik Jonsson, 5/18/2022 7:51:18 AM)

Looks like the package was either pulled or not available for all yet, all I get is ""

Scott Reed
( By Scott Reed, 5/18/2022 7:52:56 AM)

We upgraded and had a number of issues so I imagine it was rolled back.

Scott Reed
( By Scott Reed, 5/18/2022 8:06:34 AM)

https://world.optimizely.com/blogs/Erik-Skagerlind/Dates/2022/5/commerce-14-3-0-has-temporarily-been-removed-from-the-optimizely-nuget-feed/

Mari Jørgensen
( By Mari Jørgensen, 5/30/2022 1:49:24 PM)

I can see that 14.3.1 now has been released with .NET 6 support for Episerver.Commerce. Any ETA on Find-packages - when will they have .NET 6 support, @Magnus?

Magnus Rahl
( By Magnus Rahl, 6/3/2022 8:15:47 AM)

@Mari I apologize, we've had a lot of issues getting Find through our automatic testing due to reasons not related to the Find packages themselves. But it has now been cleared and should be in the release train on Tuesday.

Magnus Rahl
( By Magnus Rahl, 6/7/2022 3:07:05 PM)

@Mari Find packages were released today, version 14.1.0 supports .NET 6.

Please login to comment.