NuGet package restore and custom feeds

Posted on July 10, 2013 by Frederik Vig in EPiServer, Visual Studio

Here’s a quick tip for future reference. When enabling NuGet package restore (in Visual studio: right click your solution file and choose Enable NuGet Package restore). Benefit of this is that you don’t have to commit all the packages files to source control, which can be quite a few (more information here: Using NuGet without committing packages to source control).

Now to the problem at hand, this will work great locally for custom feeds like nuget.episerver.com that you already have added to NuGet, but on your build server you’ll get a build error for packages not on nuget.org. The fix for this is quite simple and requires you to only edit the file NuGet.targets which is located in the .nuget folder (where your solution file is located).

<ItemGroup Condition=" '$(PackageSources)' == '' ">
<!-- Package sources used to restore packages. By default, registered sources under %APPDATA%\NuGet\NuGet.Config will be used -->
<!-- The official NuGet package source (https://nuget.org/api/v2/) will be excluded if package sources are specified and it does not appear in the list -->
 
<PackageSource Include="https://nuget.org/api/v2/" />
<PackageSource Include="http://nuget.episerver.com/feed/packages.svc/" />
 
</ItemGroup>

Related Posts: