NuGet servers requiring username/password in VSTS

nuget.jpgWhen you buy a tool for your development, sometimes that tool comes via a private NuGet server which often requires a username and password.

In order to access the server, you’ll need to add these credentials to VSTS. To do this, click the Gear, then Services.

vsts1.png

Click New Service Endpoint, then choose NuGet from the list that appears.

vsts2.png

 

On the dialog that appears, select Basic Authentication and enter the details for the external NuGet server.

vsts3.png

Now go to your build definition, and choose the NuGet restore build setup you have already added there. Under Feeds and authentication, choose Feeds in my NuGet.config and enter the path to your nuget.config in the solution.

Then choose the credentials you just added in the following box.

vsts4.png

Happy Building!

Advertisements

Universal NuGet.Config: One config to rule them all

nuget.jpgNow that NuGet is fully understood by MSBuild, it’s time to look at how we can have a system-wide NuGet.config to contain all our NuGet repositories including private ones and commercial ones requiring a password. You can remove any NuGet.config files from our solutions.

Open Windows Explorer and enter %AppData%\Nuget into the address bar. It’ll open a folder with your system Nuget.config

Open this file in Notepad or Notepad++ (my favourite)

NuGet.png

To add local NuGet servers, simply add them under packageSources if they have no authentication.

If they require a username and password or you wish to add commercial NuGet servers , we can add them to NuGet.config by running the following in a CMD prompt:

For example, if you want Telerik’s server, you would run:

NuGet.exe Sources Add -Name “telerik.com” -Source “https://nuget.telerik.com/nuget” -UserName “YourEmail@email.com” -Password “Your Password”

Your NuGet.config is updated :

NuGet2.png

To see the changes in Visual Studio, restart it.


Build Server:

If your build server restores NuGet, add this file to the server folder: %ProgramFiles(x86)%\NuGet\Config