Contents

Azure Pipelines Error NETSDK1045: The current .NET SDK does not support targeting .NET 6.0

Contents

I’ve just finished doing a bunch of work in an Azure Function app targetting .NET 5.0
Now that .NET 6.0 is GA, .NET 5.0 will reach end of support in May 2022. So I upgraded it to .NET 6.0 and Functions v4.

This was all very straightforward, except when building my App in Azure Pipelines, where I got the following error:

Error NETSDK1045: The current .NET SDK does not support targeting .NET 6.0. Either target .NET 5.0 or lower, or use a version of the .NET SDK that supports .NET 6.0.

This tells me that .NET 6.0 is not yet installed on the latest hosted build agents in Azure Pipelines, and I’ll have to arrange for that myself. Fortunately, this is pretty simple, and the following task needs to be added to the pipeline before you run any dotnet command:

- task: UseDotNet@2
  displayName: 'Use dotnet 6'
  inputs:
    version: '6.0.x'

This will pull down the latest 6.0 version of dotnet, and use that when building.