When 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.
Click New Service Endpoint, then choose NuGet from the list that appears.
On the dialog that appears, select Basic Authentication and enter the details for the external NuGet server.
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.
Now 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)
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 :
To see the changes in Visual Studio, restart it.
If your build server restores NuGet, add this file to the server folder: %ProgramFiles(x86)%\NuGet\Config