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.
To fix the issue, you need to use the Use .NET Core task and select
7.x as a version.
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.
Your pipeline should work again after that!
For more details have a look at the discussion on GitHub.