Blake Rivell
Blake Rivell

Reputation: 13875

Adding a NuGet Package Source that requires credentials with VS2015

I am attempting to setup a NuGet package source that requires credentials.

Here are the instructions

I have the latest version of Visual Studio 2015 with everything up to date. I am aware of how to add a package source through the UI in VS2015, but you can't specify credentials when doing it this way.

The command they are asking me to run is:

NuGet Sources Add -Name "telerik.com" -Source "https://nuget.telerik.com/nuget" -UserName "<your login email>" -Password "<your password>"

I am aware that I need a nuget.exe to run this command, but there is a way to do this directly through VS without downloading anything isn't there?

If I download the NuGet.exe, open a command prompt and navigate to it to run that command will I then be able to see it from Visual Studio's NuGet Package Manager UI and access it from Visual Studio's NuGet Package Manager Console? I am confused on how it will integrate with Visual Studio's built in NuGet Package Manager.

Upvotes: 5

Views: 29060

Answers (4)

RoJaIt
RoJaIt

Reputation: 461

I tried the approche Blake Rivell described in his answer. It did not work for me, so I tried to use the -StorePasswordInClearText flag. (See the instruction mentioned in the question)

Then I found out the project I started working on contained a "NuGet.Config" file. The display name of the source in this file was different to the one I added via the command line (to the global "NuGet.Config" file). (Our different projects apparently use different names for it)

So it did not work, because it was not able to associate the source with credentials with the entry in my local "NuGet.Config" file.

Upvotes: 0

HydTechie
HydTechie

Reputation: 807

We can update the file Nuget.config file entry as  

<add key="Telerik" value="https://nuget.telerik.com/nuget" 
UserName ="<<[email protected]>>" 
Password ="<<password>>" />  

This let me build and run.

Upvotes: 0

Paul Maddison
Paul Maddison

Reputation: 1

If you are using SSO and the Windows credentials fix does not work for you, just sign out of Visual Studio, then sign back in again, and then restart Visual Studio; then, the 401 NuGet package source error will be fixed.

Upvotes: 0

Blake Rivell
Blake Rivell

Reputation: 13875

I figured out that you need to download nuget.exe to your computer, open up a command prompt and navigate to it. Then run the command to add the package source with credentials:

NuGet Sources Add -Name "telerik.com" -Source "https://nuget.telerik.com/nuget" -UserName "<your login email>" -Password "<your password>"

Restart Visual Studio and the Package Source is added to the list in both the Nuget UI and Nuget Command Line.

Upvotes: 12

Related Questions