Publish the Project leads to error

Hassaan Faruq 60 Reputation points
2024-11-20T23:32:56.7+00:00

On this exercise in Exercise - Publish the result to the pipeline I publish the build to the pipeline by adding this to the Azure Pipeline file.

- task: DotNetCoreCLI@2
  displayName: 'Publish the project - Release'
  inputs:
    command: 'publish'
    projects: '**/*.csproj'
    publishWebProjects: false
    arguments: '--no build --configuration Release --output $(Build.ArtifactStagingDirectory)/Release'
    zipAfterPublish: true

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: drop'
  condition: succeeded()

But after the pipeline runs, I get these errors.

##[error]Error: The process '/opt/hostedtoolcache/dotnet/dotnet' failed with exit code 1 ##[warning].NET 5 has some compatibility issues with older Nuget versions(<=5.7), so if you are using an older Nuget version(and not dotnet cli) to restore, then the dotnet cli commands (e.g. dotnet build) which rely on such restored packages might fail. To mitigate such error, you can either: (1) - Use dotnet cli to restore, (2) - Use Nuget version 5.8 to restore, (3) - Use global.json using an older sdk version(<=3) to build 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. You can learn more about the breaking changes here: https://docs.microsoft.com/en-us/dotnet/core/tools/ and https://docs.microsoft.com/en-us/dotnet/core/compatibility/ . To learn about more such changes and troubleshoot, refer here: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops#troubleshooting ##[error]Dotnet command failed with non-zero exit code on the following projects : [ '/home/vsts/work/1/s/Tailspin.SpaceGame.Web/Tailspin.SpaceGame.Web.csproj' ] Finishing: Publish the project - Release

Did the exercise files use outdated code that is no longer compatible with modern agents? If so, what do I have to do to fix this problem?

This question is related to the following Learning Module

Azure Training
Azure Training
Azure: A cloud computing platform and infrastructure for building, deploying and managing applications and services through a worldwide network of Microsoft-managed datacenters.Training: Instruction to develop new skills.
1,831 questions
0 comments No comments
{count} votes

Accepted answer
  1. Pradeep M 4,400 Reputation points Microsoft Vendor
    2024-11-21T04:03:24.8566667+00:00

    Hi Hassaan Faruq,

    Thank you for reaching out to Microsoft Q & A forum.  

    This module was originally designed to use .NET SDK 6.0, meaning that the instructions and configurations are optimized for that version. However, due to recent tool updates, some packages, such as dotnet-reportgenerator-globaltool, only support .NET 8.0 or higher. 

    To complete the exercises smoothly, we recommend the following options: 

    Use .NET SDK 8.0: The latest versions of tools like ReportGenerator are only compatible with .NET 8.0. We suggest installing .NET SDK 8.0 and updating your project settings accordingly. You can download .NET SDK 8.0 from Microsoft's .NET downloads page. 

    1.Update the SDK version: Open the project’s .csproj file and set the target framework to net8.0: 

    <TargetFramework>net8.0</TargetFramework>
    

    2.Adjust your pipeline: Update the Azure Pipelines YAML file to target .NET 8.0 by specifying dotnetSdkVersion: '8.x' in the UseDotNet@2 task: 

    variables:
      dotnetSdkVersion: '8.x'
    

    3.Check and update dependencies: Ensure that any dependencies, such as coverlet.msbuild and ReportGenerator, are compatible with .NET 8.0 by updating them to the latest versions. 

    4.Test the setup: After making these changes, run tests to confirm that code coverage reports and other functions perform correctly with .NET 8.0. 

    Note for Future Updates:  This module may be updated to include support for newer SDKs in the future. For now, using .NET SDK 8.0 will allow you to complete the exercises without compatibility issues. 

    Please feel free to contact us if you have any additional questions.    

    If you have found the answer provided to be helpful, please click on the "Accept answer/Upvote" button so that it is useful for other members in the Microsoft Q&A community.        

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Hassaan Faruq 60 Reputation points
    2024-11-21T04:02:53.77+00:00

    Never mind, I realized I made a mistake by typing --no build instead of --no-build.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.