Can’t use your pipeline in Azure DevOps with .NET7? Here is a solution!

Azure category image

After upgrading your app to a newer .NET version the cloud build agent of Azure DevOps fails. Here is what you can do against it!

.NET7 was released some days ago. Today, I upgraded one of my apps, pushed it to my Git repository hosted in Azure DevOps, and waited for the build pipeline to finish. But sadly, I received an error message

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

The reason is that the Azure VM images used for pipelines are not updated yet. It will take some time before .NET7 will be preinstalled on them.

Want More Flutter Content?

Join my bi-weekly newsletter that delivers small Flutter portions right in your inbox. A title, an abstract, a link, and you decide if you want to dive in!

To fix the issue, you need to use the Use .NET Core task and select 7.x as a version.

Use .NET Core task to install specific .NET version in Azure Pipelines
Use .NET Core task to install specific .NET version in Azure Pipelines

Insert the task before your other .NET tasks and your pipeline should work again. It will download and install the most recent .NET7 version to the agent.

Use .NET Core task in YAML syntax in Azure Pipelines
Use .NET Core task in YAML syntax in Azure Pipelines

Your pipeline should work again after that!

For more details have a look at the discussion on GitHub.


Want More Flutter Content?

Join my bi-weekly newsletter that delivers small Flutter portions right in your inbox. A title, an abstract, a link, and you decide if you want to dive in!