dotnet-outdated: Cannot connect to a private nuget server (Azure DevOps)
I have tried to run dotnet outdated but it does not work on my computer.
I have dotnet SDK 5.0.100 and the latest version of the tool 3.1.0. I also have the latest version of Microsoft.NuGet.CredentialProvider
Errors occurred while analyzing dependencies for some of your projects. Are you sure you can connect to all your configured NuGet servers? Unable to find DOTNET_HOST_PATH environment variable. If you use credential providers for your NuGet sources you need to have this set to the path to the
dotnetexecutable.
I can set manually DOTNET_HOST_PATH but it still cannot connect to my private nuget source server :
$Env:DOTNET_HOST_PATH = "$env:ProgramFiles\dotnet\dotnet.exe"
Errors occurred while analyzing dependencies for some of your projects. Are you sure you can connect to all your configured NuGet servers?
Nuget server was added with the dotnet nuget add source command (with username and PAT token as password).
The dotnet command dotnet list package --outdated works well.
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 8
- Comments: 25 (8 by maintainers)
Here in 2024, and none of these workarounds have worked for me. It’s clear that changes to the tool are needed to support using with Private NuGet Feeds from Azure DevOps.
I think the PR #493 could be rebased and adjusted to work in main again. This would at least give some logging to show exactly what is failing. For me, it runs locally, but not inside the pipeline and I have absolutely no idea why.
I’m going to dive into the code a bit more tomorrow, and see if I can get a custom build running in the pipeline with better logging. If I find anything I will add it here.
On my private vsts agent, dotnet executable is located under
/usr/bin/dotnetSo you may be able to hard set the env variable, that should fix it.Alright, I got it working finally!!!
Essentially I did what @polferov posted, and added credentials into the config file and that seemed to work. I have no idea why the credential provider doesn’t work, but I have found a slightly easier way to do this in Azure DevOps now.
My pipeline tasks:
My nuget.config:
The
NuGetAuthenticate@1task adds theVSS_NUGET_ACCESSTOKENenvironment variable for the rest of the job (source), so I use that as my access token in the config file using the%characters (source).I’m still going to submit my PR for the “Specify NuGet config” change, in case you want a different nuget.config for pipelines than for devs locally. I might also create a new formatter that looks better in Azure DevOps as currently the colouring formatting doesn’t work.
I hope someone reads this and finds it helpful.
Just a heads up for anyone that ends up here like I did trying to debug this error message.
In my case, it was due to my nuget.config file being in a sub-folder and not the root folder of my source ie with other dotnet commands and tools I was specifying the config or the config wasn’t required so I didn’t think of this as being my issue at first. Once I moved it, my self-hosted build agent was able to run the tool just fine.
Ideally this tool would allow us to specify the path to the config file but it’s not a huge deal for me to move it and now everything is working well.
Here’s what worked for me (in a local setting, not in a pipeline):
While before, dotnet restore would regularly forget any credentials, they seem to be stored for good now.
I was able to use the Nuget Authenticate task before it in order to get things working again. My issue seemed to be that dotnet-outdated-tool doesn’t appear to read the credentials used elsewhere in the pipeline.