Use a self hosted nuget gallery on your CI server

Use a self hosted nuget gallery on your CI server

24 July 2014

You may decide to host your own nuget gallery e.g. http://my-nuget-server.

Maybe you want to protect your team from internet outage or host your own private packages.

Ignoring the fact that you need to update everyone’s Visual Studio to pull from your nuget the one place you have to ensure that you use your nuget gallery is from your Continuous Integration Server; in my case Jenkins-CI.

I use the msbuild plugin to build my .NET projects with package restore enabled. This means I version a .nuget folder in my git repository.

If you don’t want to version the nuget.exe make sure to supply the parameter /p:DownloadNuGetExe=true; but I recommend you version nuget.exe to ensure repeatable builds! You never know; it might change it’s dependency resolving behaviour in a later update..?

MsBuild Configuration

I configured my msbuild plugin to pass http://my-nuget-server in as an msbuild default parameter /p:PackageSources with the value of my nuget server.

If you have a developer who accidently pulls a package from nuget.org; but fails to add it to your self hosted repository; you’ll get build failure.

Note: You may find you have done this but your CI server still seems to pull the packages; ever after you clear the workspace and/or deleted the packages folder? Remember to clear your nuget cache for the ci user. e.g. C:\Users\Colin\AppData\Local\NuGet\Cache

.NET CI Jenkins-CI