0
votes

Working on a dotnet core test pipeline, running on a Windows Self hosted agent, I have errors.

As my project uses DotNet Core 3.1 and when I run "dotnet --version" on the agent it gives 5.0.100, I thought I had to install DotNet Core 3.1 but looking at Add/Remove Programs, I see versions 3.1.301 and 5.0.100

enter image description here

My pipeline contains:

  • job: Test displayName: 'Test' steps:
    • task: UseDotNet@2 inputs: packageType: 'sdk' version: '3.1.x'

    • task: NuGetAuthenticate@0 displayName: 'Authenticate with NuGet'

    • task: DotNetCoreCLI@2 inputs: command: test projects: 'src/Tests/*.csproj' testRunTitle: 'Tests' arguments: '--collect "Code coverage"' publishTestResults: true

I added "UseDotNet" with the goal of setting the version I want to use but I got this error:

##[error]Failed to download or parse releases-index.json with error: {"code":"UNABLE_TO_GET_ISSUER_CERT_LOCALLY"}

I removed "UseDotNet" and then I had:

Info: .NET Core SDK/runtime 2.2 and 3.0 are now End of Life(EOL) and have been removed from all hosted agents. If you're using these SDK/runtimes on hosted agents, kindly upgrade to newer versions which are not EOL, or else use UseDotNet task to install the required version.

##[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

Does it mean I should migrate the entire solution to .Net 5 ? That seems like a large task...

Thanks and regards.

1
Hi @ClaudeVernier, How are thing going? Are the explanations and suggestions in my answer helpful to you? If you have any questions about this ticket, feel free to tell me.Bright Ran-MSFT
Hi! I'm sorry, I'll be away from the pc until next year... 😁ClaudeVernier

1 Answers

0
votes

If the agent contains .Net Core SDK/Runtime 5.x, unless you have locked down a SDK version for your projects, 5.x SDK might be picked up in the Azure pipelines. On Microsoft-hosted agents, .Net 5 has been set as the default version.

You get the warning,

##[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

NuGet 5.8 is the first release to support .NET 5. When using it with other tooling versions, it may cause the issue that your builds can break. You may run into issues with restoring your projects & solutions and then building them using mismatched versions of tooling. (see this article)

You can check if you have installed NuGet 5.8 or later on your agent machine.

Consider the .NET Core version of your project is older, and .NET Core 5 has been used as the default on Azure Pipelines, I recommend you update your .NET Core 3.1 project to .NET Core 5.0. You can reference to the article "Migrate from ASP.NET Core 3.1 to 5.0".