I have the following convention for most of my projects:
/src
/Solution.sln
/SolutionFolder
/Project1
/Project2
/etc..
/lib
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.
The most consistent way is by using nuget config
to explicitly set the config:
nuget config -set repositoryPath=c:\packages -configfile c:\my.config
https://docs.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior#changing-config-settings
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.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
<config>
<add key="repositorypath" value="$/../../../Common/packages" />
</config>
</configuration>
You can also use NuGet command to ensure that syntax will be correct like this:
NuGet.exe config -Set repositoryPath=$/../../../Common/packages -ConfigFile NuGet.Config
UPDATE for VS 2017:
Looks people in Nuget team finally started to use Nuget themselves which helped them to find and fix several important things. So now (if I'm not mistaken, as still didn't migrated to VS 2017) the below is not necessary any more. You should be able to set the "repositoryPath" to a local folder and it will work. Even you can leave it at all as by default restore location moved out of solution folders to machine level. Again - I still didn't test it by myself
VS 2015 and earlier
Just a tip to other answers (specifically this):
Location of the NuGet Package folder can be changed via configuration, but VisualStudio still reference assemblies in this folder relatively:
<HintPath>..\..\..\..\..\..\SomeAssembly\lib\net45\SomeAssembly.dll</HintPath>
To workaround this (until a better solution) I used subst command to create a virtual drive which points to a new location of the Packages folder:
subst N: C:\Development\NuGet\Packages
Now when adding a new NuGet package, the project reference use its absolute location:
<HintPath>N:\SomeAssembly\lib\net45\SomeAssembly.dll</HintPath>
Note:
The config file in the accepted answer works for me in VS2012. However, for me it only works when I do the following:
If I follow those steps I can use a shared package folder.
In addition to Shane Kms answer, if you've activated Nuget Package Restore, you edit the NuGet.config located in the .nuget-folder as follows:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<repositoryPath>..\..\ExtLibs\Packages</repositoryPath>
</configuration>
Notice the extra "..\", as it backtracks from the .nuget-folder and not the solution folder.