Recently upgraded my application to .NET 8.0.
Getting below error in Azure pipeline.
##[error]Error: The process '/opt/hostedtoolcache/dotnet/dotnet' failed with exit code 2
Info: Azure Pipelines hosted agents have been updated and now contain .Net 5.x SDK/Runtime along with the older .Net Core version which are currently lts. Unless you have locked down a SDK version for your project(s), 5.x SDK might be picked up which might have breaking behavior as compared to previous versions.
##[error]Dotnet command failed with non-zero exit code on the following projects : [ '' ]
I have already added task to YAML for .NET SDK 8.0.302 and .NET Core runtime 8.0.6 which are successful and after that encountering this error. What is going wrong in pipeline?
YAML :
steps:
- task: UseDotNet@2
displayName: 'Install .NET Core runtime'
inputs:
packageType: "runtime"
version: "8.0.6"
- task: UseDotNet@2
displayName: "Using DotNet@2"
inputs:
packageType: "sdk"
version: "8.0.302"
- task: DotNetCoreCLI@2
displayName: "Install dotnet format"
inputs:
command: "custom"
custom: "tool"
arguments: "update -g dotnet-format"
- task: DotNetCoreCLI@2
displayName: "Lint dotnet"
inputs:
command: "custom"
custom: "format"
arguments: "--verify-no-changes --verbosity diagnostic"
workingDirectory: backend
Detailed error message is shown below :
Azure Pipeline Error
2
Answers
Was the build tested locally before moving to CI? I suggest reviewing the breaking changes for .NET 8 and ensuring compatibility.
https://learn.microsoft.com/en-us/dotnet/core/compatibility/8.0
According to your yaml, all your
DotNetCoreCLI@2
tasks are missing parameterprojects
, which is used to specify the path to thecsproj
orsln
file(s) to use.Testing with your yaml, I can reproduce the error:
Please add
projects
as shown below:Result: