'NuGet 6 not available on Azure Pipeline
I try to update my pipeline from NET 5 to NET 6. It immediately bombed out at nuget restore saying that the used version does not support NET 6. When going to advanced settings for the NuGet tool installer therer is an i icon showing all available versions (links to https://dist.nuget.org/tools.json). That link shows 6.0.0-preview.3. If I set this and run the pipeline I get an error that latest version is 5.11.
I did add a task BEFORE to install net SDK 6 which succeeds (Successfully installed .NET Core sdk version 6.0.100-preview.3.21202.5. Creating global tool path and pre-pending to PATH.)
So why can't it find the nuget 6 ?
Solution 1:[1]
This seems to be an expected behavior.
Following line filters out releases with "EarlyAccessPreview" tag.
let releasedVersions: INuGetVersionInfo[] = nugetVersions.filter(x => x.stage.toString() !== NuGetReleaseStage[NuGetReleaseStage.EarlyAccessPreview]);
Not sure if there is any possible side effect when letting user to install preview release of nuget.exe. So the task decides to download the stable released version.
For a workaround:
You could use the powershell to download the Nuget 6.0.0- preview3.
steps:
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
# Source file location
$source = 'https://dist.nuget.org/win-x86-commandline/v6.0.0-preview3/nuget.exe'
# Destination to save the file
$destination = '$(Agent.TempDirectory)\nuget.exe'
#Download the file
Invoke-WebRequest -Uri $source -OutFile $destination
For more info, you could refer to this ticket: NuGetToolInstallerV1 cannot download preview releases
Solution 2:[2]
Azure DevOps Pipeline's NuGetCommand task is a wrapper of nuget.exe. However, I don't recommend using nuget.exe restore
to restore your projects. I bet you don't use it locally, so why not use the same tools on CI as you use for local builds.
If you build with dotnet build
, then I suggest you use dotnet restore
. If you build with msbuild
, then I suggest you restore with msbuild -t:restore
. Therefore, your pipeline should use the DotnetCoreCLI task, or MSBuild pipeline task.
Solution 3:[3]
Try updating the vm image defined in the yml file. I was getting error with windows latest but allowed for nuget restore and project/solution builds.
pool: vmImage: 'windows-2022'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Fairy Xu |
Solution 2 | zivkan |
Solution 3 | Nutzs |