Tired of Visual Studio prompting for the credentials of your Nuget Sources every time?
This method uses the nuget.exe to add sources and store its credentials.
Nuget stores its sources in the %AppData%/Nuget/nuget.config file.
When adding them from Visual Studio, it’s not possible to define (and stored) credentials, so most likely Visual Studio will prompt for credentials everytime you open a project that uses a custom source.
There is, however, another way to add these sources to this file, storing the credentials (with the password being encrypted).
To do so, it’s necessary to download the nuget.exe executable from here: https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
Then, run the following command, from the location where the executable is:
Nuget Sources Add -Name "Name of your Source" -Source "http://location_of_your_source" -UserName YourUsername -Password YourPassword
It’s recommended to use CMD and not powershell to run this command as cmd does not keep command history across sessions.
Once this is done, two entries will be added to the config file:
- One in the packageSources section with the new source
- Another in the packageSourceCredentials with the plaintext username, and encrypted password.
Now, next time you open a project, Visual Studio won’t ask again for those credentials.
Be First to Comment