Is it possible to change the location of packages for NuGet?
I have the following convention for most of my projects:
/src
/Solution.sln
/SolutionFolder
/Project1
/Project2
/etc..
/lib
/Moq
moq.dll
license.txt
/Yui-Compressor
yui.compressor.dll
/tools
/ILMerge
ilmerge.exe
You'll notice that I do not keep external libraries inside the source folder. I'm also very interested in using NuGet but don't want these external libraries inside the source folder. Does NuGet have a setting to change the directory that all packages are loaded into?
It's now possible to control which folder the packages are installed into.
http://nuget.codeplex.com/workitem/215
Edit: See Phil Haack's comment on Dec 10 2010 at 11:45 PM (in the work item/the link above). The support is partially implemented in 1.0, but is not documented.
According to @dfowler: Add a nuget.config file next to the solution with this:
<settings>
<repositoryPath>{some path here}</repositoryPath>
</settings>
There is a nuget package for creating the package folder override.
Update for version 2.1
As Azat commented, there is now official documentation on how to control the package locations. The release notes for 2.1 specifies the following configuration in a nuget.config file (see the release notes for a description of valid places to put the config files and how the hierarchical configuration model works):
<configuration>
<config>
<add key="repositoryPath" value="C:\thePathToMyPackagesFolder" />
</config>
...
</configuration>
This would change the packages folder for the configuration level you put the file in (solution if you put it in the solution directory, project in project directory and so on). Note that the release notes state:
[...] if you have an existing packages folder underneath your solution root, you will need to delete it before NuGet will place packages in the new location.
- Created a file called "nuget.config".
- Added that file to my solutions folder
this did NOT work for me:
<configuration>
<config>
<add key="repositoryPath" value="..\ExtLibs\Packages" />
</config>
...
</configuration>
this did WORK for me:
<?xml version="1.0" encoding="utf-8"?>
<settings>
<repositoryPath>..\ExtLibs\Packages</repositoryPath>
</settings>