0
votes

Recently we migrated a .NET Core 3.1 project to .NET 5.0. We have few pipelines setup using AzureDevOps

On Modifying the version of .NET Core SDK task from 3.1.x to 5.0; we faced the below exception

##[error]Version 5.0 is not allowed. Allowed version types are: majorVersion.x, majorVersion.minorVersion.x, majorVersion.minorVersion.patchVersion. More details: The version number: 5.0 doesn't have the correct format. Versions can be given in the following formats: 2.x => Install latest in major version. 2.2.x => Install latest in major and minor version. 2.2.104 => Install exact version. Find the value of version for installing SDK/Runtime, from the releases.json. The link to releases.json of that major.minor version can be found in releases-index file.. Like link to releases.json for 2.2 version is https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/2.2/releases.json

Has AzureDevOps not been updated to .NET 5.0 or do we have to run test projects and pipelines only in .NET Core 3.1.x?

Also we are unable to locate any Agent job task available for .NET 5.0 in the Marketplace tab while creating the tasks.

1
Can you share your pipeline? You have an error message, but not the code that triggers the error? Based on the error, my suspect is you have a 5.0 version string when it expects 5.0.x (extra .x needed). - omajid
It was resolved by the answer given below. Manual config on Yaml is best way to go. However agreed when I used 5.0.10 in version number and ignored global.json it worked as well. - Aditya

1 Answers

1
votes

You probably need to use UseDotNet task to get the .NET 5.0 downloaded and used in subsequent dotnet build task. See below example:

- task: UseDotNet@2
  displayName: 'Install .Net 5 SDK'
  inputs:
    packageType: 'sdk'
    version: '5.0.100'

- task: DotNetCoreCLI@2
  inputs:
    command: 'build'