restore command (NuGet CLI)
Applies to: package consumption • Supported versions: 2.7+
NuGet 2.7+: Downloads and installs any packages missing from the
NuGet 3.3+ with projects using
project.json: Generates a
project.lock.json file and a
<project>.nuget.props file, if needed. (Both files can be omitted from source control.)
NuGet 4.0+ with project in which package references are included in the project file directly: Generates a
<project>.nuget.props file, if needed, in the
obj folder. (The file can be omitted from source control.)
On Mac OSX and Linux with the CLI on Mono, restoring packages is not supported with the PackageReference format.
nuget restore <projectPath> [options]
<projectPath> specifies the location of a solution, a
packages.config file, or a
project.json file. See Remarks below for behavioral details.
|ConfigFile||The NuGet configuration file to apply. If not specified, %AppData%\NuGet\NuGet.Config is used.|
|DirectDownload||(4.0+) Downloads packages directly without populating caches with any binaries or metadata.|
|DisableParallelProcessing||Disables restoring multiple packages in parallel.|
|FallbackSource||(3.2+) A list of package sources to use as fallbacks in case the package isn't found in the primary or default source.|
|ForceEnglishOutput||(3.5+) Forces nuget.exe to run using an invariant, English-based culture.|
|Help||Displays help information for the command.|
|MSBuildPath||(4.0+) Specifies the path of MSBuild to use with the command, taking precedence over
|MSBuildVersion||(3.2+) Specifies the version of MSBuild to be used with this command. Supported values are 4, 12, 14, 15. By default the MSBuild in your path is picked, otherwise it defaults to the highest installed version of MSBuild.|
|NoCache||Prevents NuGet from using packages from local machine caches.|
|NonInteractive||Suppresses prompts for user input or confirmations.|
|OutputDirectory||Specifies the folder in which packages are installed. If no folder is specified, the current folder is used.|
|PackageSaveMode||Specifies the types of files to save after package installation: one of
|Project2ProjectTimeOut||Timeout in seconds for resolving project-to-project references.|
|Recursive||(4.0+) Restores all references projects for UWP and .NET Core projects. Does not apply to projects using
|RequireConsent||Verifies that restoring packages is enabled before downloading and installing the packages. For details, see Package Restore.|
|SolutionDirectory||Specifies the solution folder. Not valid when restoring packages for a solution.|
|Source||Specifies list of package sources (as URLS) to use for the restore.|
|Verbosity||>Specifies the amount of detail displayed in the output: normal, quiet, detailed (2.5+).|
Also see Environment variables
The restore command performs the following steps:
Determine the operation mode of the restore command.
projectPath file type Behavior Solution (folder) NuGet looks for a
.slnfile and uses that if found; otherwise gives an error.
(SolutionDir)\.nugetis used as the starting folder.
Restore packages identified by the solution; gives an error if
$(SolutionDir)\.nugetis used as the starting folder.
project.json, or project file
Restore packages listed in the file, resolving and installing dependencies. Other file type File is assumed to be a
.slnfile as above; if it's not a solution, NuGet gives an error.
(projectPath not specified) - NuGet looks for solution files in the current folder. If a single file is found, that one is used to restore packages; if multiple solutions are found, NuGet gives an error. - If there are no solution files, NuGet looks for a
project.jsonand uses that to restore packages.
- If no solution file,
project.jsonis found, NuGet gives an error.
Determine the packages folder using the following priority order (NuGet gives an error if none of these folders are found):
- The folder specified with
- The folder specified with
When restoring packages for a solution, NuGet does the following:
- Loads the solution file.
- Restores solution level packages listed in
- Restore packages listed in
packagesfolder. For each package specified, restore the package in parallel unless
# Restore packages for a solution file nuget restore a.sln # Restore packages for a solution file, using MSBuild version 14.0 to load the solution and its project(s) nuget restore a.sln -MSBuildVersion 14 # Restore packages for a project's packages.config file, with the packages folder at the parent nuget restore proj1\packages.config -PackagesDirectory ..\packages # Restore packages for the solution in the current folder, specifying package sources nuget restore -source "https://www.nuget.org/api/v2;https://www.myget.org/F/nuget"