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.
NuGet 2.1 offers a feature that makes this a lot simpler: just do update-package -reinstall -ignoreDependencies
from the Package Manager Console.
NuGet 2.0 doesn't handle re-targeting your applications very well. In order to change your packages' target frameworks, you must uninstall and reinstall the packages (taking note of the packages you had installed so that you can reinstall each of them).
The reason packages must be uninstalled and reinstalled is:
- When installing a package, we determine the target framework of your project
- We then match that up with the package contents, finding the appropriate \lib\ folder (and \content\ folder)
- Assembly references are added with Hint Paths that point to the package's \lib\ folder, with the right subfolder (\lib\net40 for example)
- Content files are copied from the packages \content\ folder, with the right subfolder (\content\net40 for example)
- We record the targetFramework used to install the package within the packages.config file
- After you change your project's target framework, the Hint Paths still point to net40
- When you uninstall packages, we check the targetFramework that was recorded in packages.config to see what target framework's libs/content to remove from your project
- When you reinstall the package, we detect your updated target framework and reference/copy the right libs/content
Best Answer
You can use nuget.exe to restore your packages or with NuGet 2.7, or above, installed you can simply compile your solution in Visual Studio, which will also restore the missing packages.
For NuGet.exe you can run the following command for each project.
Or with NuGet 2.7 you can restore all packages in the solution using the command line.
Both of these will pull down the packages. Your project files will not be modified however when running this command so the project should already have a reference to the NuGet packages. If this is not the case then you can use Visual Studio to install the packages.
With NuGet 2.7, and above, Visual Studio will automatically restore missing NuGet packages when you build your solution so there is no need to use NuGet.exe.
To update all the packages in your solution, first restore them, and then you can either use NuGet.exe to update the packages or from within Visual Studio you can update the packages from the Package Manager Console window, or finally you can use the Manage Packages dialog.
From the command line you can update packages in the solution to the latest version available from nuget.org.
Note that this will not run any PowerShell scripts in any NuGet packages.
From within Visual Studio you can use the Package Manager Console to also update the packages. This has the benefit that any PowerShell scripts will be run as part of the update where as using NuGet.exe will not run them. The following command will update all packages in every project to the latest version available from nuget.org.
You can also restrict this down to one project.
If you want to reinstall the packages to the same versions as were previously installed then you can use the
-reinstall
argument withUpdate-Package
command.You can also restrict this down to one project.
The
-reinstall
option will first uninstall and then install the package back again into a project.Or, you can update the packages using the
Manage Packages
dialog.Updates:
-reinstall