BaltoStar
BaltoStar

Reputation: 8997

Visual Studio : NuGet Package Source requires credentials

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.

Upvotes: 30

Views: 51289

Answers (3)

Lukas Willin
Lukas Willin

Reputation: 582

Old question but still relevant. I am not sure as to what exactly leads to NuGet being unable to use the "Windows authentication broker", but at least for me that was the issue in the end.

Go to Tools > Options > Accounts and select anything but the "Windows authentication broker". Log out and back into your accounts via the new sign in option. And for good measure restart VS.

Go to Tools > Options > Accounts and select anything but the "Windows authentication broker"

To be frank: I don't understand why NuGet (within VS) doesn't use the Credentials provided via the %AppData%\NuGet\NuGet.config file. They work just fine when using dotnet restore or nuget restore from either PowerShell or cmd shell (even from VSs inbuilt PowerShell window). But it is what it is.

I also answered this question here: https://stackoverflow.com/a/79274415/6289706

Upvotes: 1

ADM-IT
ADM-IT

Reputation: 4200

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.

Upvotes: 1

Mike Perrenoud
Mike Perrenoud

Reputation: 67928

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.

Upvotes: 40

Related Questions