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!