Search code examples
azure-devopsnuget-packagedotnet-tool

Cannot install a specific version of dotnet tool in Azure DevOps pipeline


I am trying to install a version of a dotnet tool and it works for older versions but for the latest version, for some reason, it just won't install

dotnet new tool-manifest
dotnet tool install foo --version 2.0.0 // this doesn't work
dotnet tool install foo --version 1.1.1 // this works, same feed both hosted on Azure DevOps Artifacts

The same nuget.config file is present in the repo. The only difference is the version number. I can confirm both versions exist on our Artifacts.

error NU1301: Unable to load the service index for source '...'
The tool package couild not be restored.
Tool 'foo' failed to install. This failure may have been caused by:

* You are attempting to install a preview release and did not use the --version option to specify the version.
* A package by this name was found, but it was not a .NET Core tool.
* The required NuGet feed cannot be accessed, perhaps because of an Internet connection problem.
* You mistyped the name of the tool.

Solution

  • I found out the issue. Since this is a different feed that is not in the same organization, I created a service connection in Azure DevOps to connect to this feed. Seems like the PAT may have been broken (maybe deleted by accident or wrong scopes?). I generated a new token and used it and it fixed the issue. I believe the reason the old version was working is because the Azure DevOps self hosted build agent already had the tool cached.