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?
this did NOT work for me:
this did WORK for me:
Okay for the sake of anyone else reading this post - here is what I understand of the myriad of answers above:
The nuget.config file in the .nuget folder is relative to that folder. This is important because if your new folder is something like '../Packages' that will put it where it always goes out of the box. As @bruce14 states you must do '../../Packages' instead
I could not get the latest nuget (2.8.5) to find a packages folder outside of the standard location without enabling package restore. So once you enable package restore then the following should be added to the nuget.config file inside of the .nuget folder to change the location:
(This is important) If you make ANY changes to the package folder location inside of the nuget.config files you must restart visual studio or close/reload the solution for the changes to take effect
A solution for Nuget 3.2 on Visual Studio 2015 is:
Using forward slash for parent folder. Save above file (nuget.config) in solution folder.
Reference is available here
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:
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):
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:
None of this answers was working for me (Nuget 2.8.6) because of missing some tips, will try to add them here as it might be useful for others.
After reading the following sources:
https://docs.nuget.org/consume/NuGet-Config-Settings
https://github.com/NuGet/Home/issues/1346
It appears that
E.g.
You can also use NuGet command to ensure that syntax will be correct like this:
Just updating with Nuget 2.8.3. To change the location of installed packages , I enabled package restore from right clicking solution. Edited NuGet.Config and added these lines :
Then rebuilt the solution, it downloaded all packages to my desired folder and updated references automatically.