skip to Main Content

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


  1. 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

    Login or Signup to reply.
  2. According to your yaml, all your DotNetCoreCLI@2 tasks are missing parameter projects, which is used to specify the path to the csproj or sln file(s) to use.

    Testing with your yaml, I can reproduce the error:

    enter image description here

    Please add projects as shown below:

    - task: DotNetCoreCLI@2
      displayName: "Install dotnet format"
      inputs:
        command: 'custom'
        projects: '**/*.csproj'
        custom: 'tool'
        arguments: 'update -g dotnet-format'
    - task: DotNetCoreCLI@2
      displayName: "Lint dotnet"
      inputs:
        command: 'custom'
        projects: '**/*.csproj'
        custom: 'format'
        arguments: '--verify-no-changes --verbosity diagnostic'
    

    Result:

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search