Let’s upgrade my main site and podcast to .NET 6 LTS

[ad_1]


.NET 6 is released and it’s a LTS release which means it’ll be fully and actively supported for the next 3 years. If you’ve been paused waiting for the right time to upgrade to .NET 6, it’s a good time to make the move!

Right now, Hanselman.com and Hanselminutes.com (my podcast) are running on some version of .NET 5. You can se by visiting them and scrolling to the very bottom in the footer as I’ve added a git commit hash and Azure DevOps Build Number and Build ID to an ASP.NET website and I’m using RuntimeInformation.FrameworkDescription to output the plain text version of .NET I’m using. This blog is on .NET Core 3.0 which is an LTS release but I’ll be working with Mark Downie this week to move it to .NET 6 LTS as he’s already got his instance of dasBlog running on 6!

© Copyright 2021, Scott Hanselman. Design by @jzy, Powered by .NET 5.0.10 and deployed from commit e5058e via build 20210920.3

OK, let’s see what’s involved. Let’s start with my podcast site. I’ve got the code on GitHub and running locally with “dotnet run” on the command line in both Linux and Windows. I can run the “dotnet upgrade assistant” which is great, but I also like to drive stick shift sometimes for smaller projects.

I’ll update my TargetFramework in my csproj project file from net5.0 to net6.0 and update the major PackageReferences from 5.0.0 to 6.0.0. It compiles.

Optionally, I’ll also run “dotnet outdated” which is one of my favorite tools. You’ll want to make sure you have a solid test suite and not just do this without testing.

dotnet outdated tells me which packages need updating

I see that some of these are major changes so I can do a diff of these packages with a number of tools, but my favorite is FuGet.org (Thanks Frank!) so I can do a diff between the alpha version of Selenium I’m using and the released see that the RemoteLogs type is now called Logs.

I will also update my Dockerfile and change versions like this

FROM mcr.microsoft.com/dotnet/sdk:6.0 as build

and

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS runtime

I’ll confirm that these images build and test. I also run my tests optionally inside a container so that’s nice.

Some of my sites use Azure DevOps and others use GitHub Actions. Both use YAML (yay) to manage their config, so I’ll update my UseDotNet task in Azure DevOps YAML to version: “6.0.x”

I’ll commit and start building in the cloud!

Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: Dockerfile
modified: azure-pipelines.yml
modified: hanselminutes.core.tests/SeleniumTests.cs
modified: hanselminutes.core.tests/hanselminutes.core.tests.csproj
modified: hanselminutes.core/Startup.cs
modified: hanselminutes.core/hanselminutes-core.csproj

$ git commit -m "upgrade to .net 6"

I will also confirm that my Azure App Service is set to .NET 6, but this is only needed if I’m NOT running in a Docker Container or if I’m NOT using a self-contained executable.

Now I repeat this for my podcast and main site and I’m now on .NET 6! The blog (a larger upgrade) is next.


Sponsor: Lob’s developer-friendly APIs make it easy to send a letter, check, or postcard, as easily as email. Design dynamic HTML templates to personalize mail for maximum impact. Start Exploring with Postman!




About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook
twitter
subscribe
About   Newsletter

Hosting By
Hosted in an Azure App Service










[ad_2]

Leave a Reply