This is the error I get:
This is my configuration:
Can anyone help me?
When you set the .NET Core SDK version to 3.x, it automatically download and install the latest in major version SDK 3.1.401, but SDK 3.1.401 is included in Visual Studio 16.7.1. Since the hosted agent installed Visual Studio 16.6.30320.27, which doesn't include SDK 3.1.401, you would get the error during the build.
Currently, you could set the .NET Core SDK version to 3.1.302, or 3.1.107, which should solve your issue.
https://dotnet.microsoft.com/download/dotnet-core/3.1
This issue has been reported to product team in the following case, you can follow the case to track the status:
I fix that for the latest .NET release. The issue can be fixed with this line of code in your pipeline (.yaml) file.
steps:
- task: UseDotNet@2
displayName: 'Use .NET Core sdk 6.0.x'
inputs:
version: 6.x
includePreviewVersions: true
Just add the above step to your YAML file.