Get Started with Optimizely and .net6
Get started with Alloy template on .net 6 in 3 minutes.
Published 17th April 2022
Optimizely CMS 12
Read this first
This post is not valid anymore. The Episerver Templates are automatically .net6 or later after may 2022. Anyhow, it shows how to update .net version on a solution.
Easy install with “dotnet new”
Open command prompt in new directory
Install the Optimizely .net Templates:
dotnet new install EPiServer.Templates
Install the the Alloy .net5 Template:
(out of the box the template is .net5 – at time writing)
dotnet new epi-alloy-mvc --name Epicweb.AlloyDot.Net6
Now upgrade to .net6
notepad Epicweb.Alloy.Net6.csproj
replace <TargetFramework>net5.0</TargetFramework>
with <TargetFramework>net6.0</TargetFramework>
replace <PackageReference Include=”EPiServer.CMS” Version=”12.3.0″ />
with
<PackageReference Include="EPiServer.CMS" Version="12.4.0" />
<PackageReference Include="EPiServer.CloudPlatform.Cms" Version="1.0.4" />
<!-- Extra top level dependencies needed to force CMS 6 compatible version of CMS Core -->
<PackageReference Include="EPiServer.CMS.AspNetCore.HtmlHelpers" Version="12.5.0" />
<PackageReference Include="EPiServer.Hosting" Version="12.5.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.2" />
<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" />
Above forces to use .net6 assemblies, read more here and here
DONE! now run the app
dotnet run
(You will get dependency warnings, but they will be resolved – read more here)
Open web browser and go to https://localhost:5000
How do I check runtime target framework?
open _root.cshtml, add
<h1>@System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription</h1>
There you are! working with the fastest .net version so far!
About the author
Luc Gosso
– Independent Senior Web Developer
working with Azure and Optimizely
Twitter: @LucGosso
LinkedIn: linkedin.com/in/luc-gosso/
Github: github.com/lucgosso