27
Visual Studio 2012 > Tools > Options > Package Manager > Package Sources

I add a new Package Source pointing to a myget.org url :

http://www.myget.org/F/myfeed/

VS > Tools > Library Package Manager > Manage NuGet Packages for Solution...

I am now prompted for myget credentials. Obviously, it will be inconvenient for developers to have to manually enter credentials every time they work with myget packages.

This blog explains how to store credentials in the machine-level NuGet.config :

https://gist.github.com/xavierdecoster/3205826

but after I follow the steps, VS still prompts me for credentials.

BaltoStar
  • 8,165
  • 17
  • 59
  • 91
  • Is this your issue? http://nuget.codeplex.com/workitem/2114 – Sumo Mar 20 '13 at 23:37
  • 1
    If no proxy involved, feel free to share a sanitized fiddler trace. – Xavier Decoster Mar 21 '13 at 09:01
  • I guess I am having the same issue and from what I can tell from Fiddler VS 2012 doesn't sent Authentication header unless I supply credentials via its "login" dialog. Almost as if it ignores the packageSourceCredentials section (doesn't matter if it's in the global NuGet.config of the one within the solution) – Pavel Veller Aug 20 '14 at 01:09

2 Answers2

37

One approach is to use the sources command:

nuget.exe sources Add|Update -Name feedName -UserName user -Password secret

With this you can either add that source with the credentials or update an existing one. It works perfectly.

Mike Perrenoud
  • 66,820
  • 29
  • 157
  • 232
  • 6
    The problem I have run into with this, is that it is not smart enough to apply those credentials to everything after the registered url. Example, if you set username/pwd to source url of http://my.nuget.org/local, it will work perfectly. However if you try to push to http://my.nuget/org/local/common, it will prompt you for your credentials again. I wish there was a way to register a url with a wildcard at the end or set global credentials that would be used by default for all registered sources. This currently encourages people to just dump everything in one folder. – Patrick May 13 '15 at 14:51
  • 1
    This is the exact problem I'm seeing with a private repo. Still no way to fix this? – Tim Schmidt Mar 30 '16 at 16:44
  • This is what I needed to add credentials to an existing NuGet source in GitHub Actions – jhhwilliams Aug 12 '21 at 13:04
  • The name specified cannot be empty. Please provide a valid name. I hate long command lines, they always go wrong – Paul McCarthy Apr 20 '23 at 23:43
0

VS 2022:

If your nuget source is accessible from your Microsoft or Git Account, just apply your credentials to the Visual Studio itself and the problem will disappear. Please see the right upper corner in VS:

Visual Studio Account Settings

Or go to the menu: File -> Account Settings.

ADM-IT
  • 3,719
  • 1
  • 25
  • 26