We recently upgraded a number of Microservices from ASP.NET Core 2.1 to 2.2 using the excellent upgrade guide on the Microsoft docs site.  After the upgrade all of our services built and ran correctly with a full suite of green unit tests. Everything was labelled with a shiny works on my machine badge and committed to source control.

We use Azure DevOps for our CI builds so when we pushed the changes up the build kicked off but it failed almost instantly on the NuGet restore step.

Digging into the logs the following error message had cropped up:

"error NETSDK1045: The current .NET SDK does not support targeting .NET Core 2.2.  Either target .NET Core 2.1 or lower, or use a version of the .NET SDK that supports .NET Core 2.2"

The build is set up to use the "Hosted VS2017" build agent and it looks like these agents don't currently have ASP.NET Core 2.2 installed.

The Solution

Azure DevOps now has a pre-canned ".NET Core SDK Installer" step which can be added to your build pipeline. If you insert that step at the top of the pipeline before the NuGet restore step runs and set the "Version" property to "2.2.100" the build will succeed.

A full list of SDK version numbers can be found on GitHub.

I'm sure there will be plans for the hosted agents to have ASP.NET Core 2.2 installed and things will start to just work without the workaround described in this post.

I've not tried this yet but the same solution should work for building ASP.NET Core Core 3 apps on Azure DevOps with the version set to "3.0.100-preview-009812", not this will likely change soon after this post is published.