11

Whenever I update my NuGet packages in Visual Studio, I am prompted for a username and password regarding a private NuGet feed.

enter image description here

Despite me ticking the box [✓] Remember my password, I am prompted to enter password on subsequent NuGet updates.

How can I make it remember my password properly?

Pang
  • 9,564
  • 146
  • 81
  • 122
Mark
  • 2,175
  • 20
  • 23

1 Answers1

12

This is a prompt from Visual Studio and not NuGet. Information entered here is not saved with NuGet. Although it should be cached for the current Visual Studio session.

NuGet stores user names and passwords in its NuGet.Config file. You can save usernames and passwords for protected feeds by adding them to the NuGet.Config file using the nuget.exe command line.

NuGet.exe Sources Update -Name <feedName> -Source <pathToPackageSource> -UserName xxx -Password <secret>

If this is a prompt for a proxy then you can either set it using nuget:

NuGet.exe config -Set HTTP_PROXY=http://127.0.0.1 -Set HTTP_PROXY.USER=domain\user

Or use an environment variable http_proxy with the value specified in the format http://[username]:[password]@proxy.com

Matt Ward
  • 47,057
  • 5
  • 93
  • 94
  • how do I get access to the nuget.exe command line. Is this the Package Manager console? – Mark Mar 11 '16 at 14:21
  • 1
    NuGet.exe is a separate command line application you can [download](https://docs.nuget.org/consume/installing-nuget) – Matt Ward Mar 12 '16 at 14:29
  • This worked for me the day I ran the command, but then the next morning I was prompted for credentials again. – Rich Feb 08 '18 at 15:54
  • The better was to show the config example with password after applied command. In 99% of cases there is no nuget.exe installed, while nuget client is part of VS 2017 + – Artem A Feb 04 '21 at 15:33