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 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s