Getting Nuget-packages from EPiServer feed without committing them to source control

If you’re using NuGet 1.6 it’s possible to not commit NuGet packages to your source control. There’s a small gotcha involved if you’re using packages that are not in the official feed (for instance, the EPiServer feed).

For this example…

Let’s imagine we have install a standard CMS6 R2 alloy tech site and added the PageTypeBuilder package. To enable the functionality of downloading needed packages automatically right click your solution and click “Enable NuGet Package restore”.

When you build the solution NuGet will check for missing packages and download them. But since we’re using the EPiServer feed we might get into trouble with people who haven’t added that feed. What happens is that NuGet by default uses the feeds defined in %AppData%\NuGet\NuGet.config. If you’ve ever downloaded a package from the EPiServer feed chanses are that you have this feed in the default config but not everyone may have done so. To fix this we can edit the nuget.target that gets created in the .NuGet folder (as part of the “Enable NuGet Package restore” step) and add the feeds manually.

Adding feeds

Change the row

<!-- From this -->
<PackageSources>""</PackageSources>

<!-- To this -->
<PackageSources>"http://nuget.episerver.com/feed/packages.svc/;https://go.microsoft.com/fwlink/?LinkID=230477"</PackageSources>

Now when we build the solution NuGet will download all the needed packages (using the feeds we added) and we no longer have a need to store them in our source control.