Using additional NuGet Package Sources on a Build Server

Now we can see the new package source on our machines, and download all kinds of fun things from it. But how do we give other servers (e.g. a build server) knowledge of this new package source?

NuGet already thought of this (thank you kindly).  Check out the NuGet.targets file (once you’ve enabled Package Restore on the solution).  You’ll want to look for a <PackageSources> element.  It may be a little convoluted, and you’ll see a few Condition=” $(PackageSources) = ” thrown around (just ignore those).  What you are looking for is the element itself.

By default, if you do not specify any package sources, NuGet will use https://www.nuget.org/api/v2/.  The minute you specify a package source, NuGet will NOT use the default nuget.org package source unless you explicity say to.

That just means you’ll need to add BOTH your new package source, and the NuGet default source (in a semi-colon separate list).  You will add these to the <PackageSources> element.

<!-- NuGet command -->
<!-- ... -->
<PackageSources ...>
https://www.nuget.org/api/v2/;\\MYSERVER\MySharedFolder
</PackageSources>

Now your can freely enable NuGet Package Restore and your build server can find your packages with ease!

Advertisements

Your Thoughts?

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s