I217;ve recently returned from a month in South Africa and I was looking to unwind while the jetlagged kids sleep. I noticed that .NET Core 2.2 Preview 3 came out while I wasn’t paying attention. My podcast site runs on .NET Core 2.2 Preview 2 so I thought it’d be interesting to update the site. That means I’d need to install the new SDK, update the project references, ensure it builds in Azure DevOps‘s CI/CD Pipeline, AND deploys and runs in Azure.
Let’s see how it goes. I’m a little out of it but I’m writing this blog post AS I DO THE WORK so you’ll see my train of thought with no editing.
Ok, what version of .NET Core does this machine have?
C:Usersscott> dotnet --version
C:Usersscott> dotnet tool update --global dotnet-outdated
Tool 'dotnet-outdated' was successfully updated from version '2.0.0' to version '2.1.0'.
Looks like I’m on Preview 2 as I guessed. I’ll take a moment and upgrade one Global Tool I love – dotnet-outdated – in case it’s been updated since I’ve been out. Looks like it has a minor update. Dotnet Outdated is a great utility for checking references and you should absolutely be using it or another tool like NuKeeper or Dependabot.
I’ll head over to https://www.microsoft.com/net/download/dotnet-core/2.2 and get .NET Core 2.2 Preview 3. I’m building on Windows but I may want to update my Linux (WSL) install and Docker images later.
All right, installed. Check it with dotnet –version to confirm it’s correct:
C:Usersscott> dotnet --version
D:githubhanselminutes-core [main ≡]> dotnet build
Microsoft (R) Build Engine version 15.9.8-preview+g0a5001fc4d for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restoring packages for D:githubhanselminutes-corehanselminutes.core.testshanselminutes.core.tests.csproj...
Restore completed in 80.05 ms for D:githubhanselminutes-corehanselminutes.core.testshanselminutes.core.tests.csproj.
Restore completed in 25.4 ms for D:githubhanselminutes-corehanselminutes.corehanselminutes-core.csproj.
D:githubhanselminutes-corehanselminutes.core.testshanselminutes.core.tests.csproj : error NU1605: Detected package downgrade: Microsoft.AspNetCore.App from 2.2.0-preview3-35497 to 2.2.0-preview2-35157. Reference the package directly from the project to select a different version. [D:githubhanselminutes-corehanselminutes-core.sln]
The dotnet build fails, which make sense, because it’s saying hey, you’re asking for 2.2 Preview 2 but I’ve got Preview 3 all ready for you!
Detected package downgrade: Microsoft.AspNetCore.App from 2.2.0-preview3-35497 to 2.2.0-preview2-35157
Cool! I love these dependency tools and the community around them. You can see that it’s noticed the Preview 2 -> Preview 3 opportunity, as well as a few other smaller minor or patch version bumps.
I can run dotnet outdated -u to automatically update the references, but I’ll want to treat the “reference” of “Microsoft.AspNetCore.App” a little differently and use implicit versioning. You don’t want to include a specific version – as I did – for this package.
Per the docs for .NET Core 2.1 and up:
Remove the “Version” attribute on the package reference to
Microsoft.AspNetCore.App. Projects which use
<Project Sdk="Microsoft.NET.Sdk.Web">do not need to set the version. The version will be implied by the target framework and selected to best match the way ASP.NET Core 2.1 works. (See below for more information.)
It builds locally, will it build in Azure DevOps when I check it in to GitHub?
I added a .NET Core SDK installer step when I set up my Azure Dev Ops Pipeline. This is where I’m explicitly installing a Preview version of the .NET Core SDK.
While I’m in here I noticed the Azure DevOps pipeline was using NuGet 4.4.1. I run “nuget update -self” on my local machine and got 4.7.1, so I updated that version as well to make the CI/CD pipeline reflect my own machine.
Now I’ll git add, git commit (using verified/signed GitHub commits with my PGP Key and Yubikey):
D:githubhanselminutes-core [main ≡ +0 ~2 -0 !]> git add .
D:githubhanselminutes-core [main ≡ +0 ~2 -0 ~]> git commit -m "bump to 2.2 Preview 3"
[main 7a84bc7] bump to 2.2 Preview 3
2 files changed, 16 insertions(+), 13 deletions(-)
Add in a Git Push…and I can see the build start in Azure DevOps:
Cool. While that’s building, I’ll make sure my existing Azure App Service (website) installation is ready to receive the deployment (assuming the build succeeds). Since I’m using an ASP.NET Core Preview build I’ll want to make sure I have the Preview Site Extension installed, per the docs.
If I visit the Site Extensions menu item in the Azure Portal I can see I’ve got .NET Core 2.2 Preview 2, but there’s an update available, as expected.
I’ll click this extension and then click Update. This extension’s job is to make sure the App Service gets Preview versions of the .NET Core SDK. Only released (GA – general availability) SDKs are installed by default.
OK, .NET Core 2.2 is all updated in Azure, so I’ll confirm that it’s deployed as well in Azure DevOps. Yes, I’m deploying into Production without a net. Seriously, though, if there is an issue I’ll just rollback. If I was deeply serious about downtime I’d be doing all this in Staging.
Successful local test, successful CI/SD build and test, successful deployment, and the site is back up now running on ASP.NET Core 2.2 Preview 3. It took about 45 min to do the work while simultaneously taking these screenshots and writing this blog post during the slow parts.
Good night everyone!
Sponsor: Check out the latest JetBrains Rider with built-in spell checking, enhanced debugger, Docker support, full C# 7.3 support, publishing to IIS and more advanced Unity support.