Share NuGet Packages between Visual Studio solutions

NuGet is getting more and more important in a (Visual Studio/Xamarin Studio) developers life. So we all come to the point, when we use NuGet packages in some core-libraries which we share across assemblies in multiple solutions.

By default, the packages are stored in the packages-folder in the solution’s root folder. So if you use project X both in solution A and solution B the NuGet packages would be used from the solution A package folder (this counts also for solution B).

There’s quite a simple trick to share the packages across all your projects. When you reference a NuGet package, NuGet is looking for a NuGet.config file to find out the repository path (= where to store the package).

So if you place a NuGet.config file in the repository root folder, all NuGet packages are going to be stored at the location you declared in the configuration file. Here’s a sample configuration which works on Windows and on the MAC:

<?xml version="1.0" encoding="utf-8"?>
     <add key="repositorypath" value="lib/nuget" />

Using this configuration all the packages referenced in whole repository will be stored in the .\lib\nuget folder in your repository.


Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht.