dotnet-restore - Man Page
Restores the dependencies and tools of a project.
Examples (TL;DR)
- Restore dependencies for a .NET project or solution in the current directory:
dotnet restore
- Restore dependencies for a .NET project or solution in a specific location:
dotnet restore path/to/project_or_solution
- Restore dependencies without caching the HTTP requests:
dotnet restore --no-cache
- Force all dependencies to be resolved even if the last restore was successful:
dotnet restore --force
- Restore dependencies using package source failures as warnings:
dotnet restore --ignore-failed-sources
- Restore dependencies with a specific verbosity level:
dotnet restore --verbosity quiet|minimal|normal|detailed|diagnostic
dotnet restore
Synopsis
.NET Core 2.x
dotnet restore [<ROOT>] [--configfile] [--disable-parallel] [--force] [--ignore-failed-sources] [--no-cache] [--no-dependencies] [--packages] [-r|--runtime] [-s|--source] [-v|--verbosity] [--interactive] dotnet restore [-h|--help]
.NET Core 1.x
dotnet restore [<ROOT>] [--configfile] [--disable-parallel] [--ignore-failed-sources] [--no-cache] [--no-dependencies] [--packages] [-r|--runtime] [-s|--source] [-v|--verbosity] dotnet restore [-h|--help]
* * * * *
Description
The dotnet restore
command uses NuGet to restore dependencies as well as project-specific tools that are specified in the project file. By default, the restoration of dependencies and tools are executed in parallel.
To restore the dependencies, NuGet needs the feeds where the packages are located. Feeds are usually provided via the nuget.config configuration file. A default configuration file is provided when the CLI tools are installed. You specify additional feeds by creating your own nuget.config file in the project directory. You also specify additional feeds per invocation at a command prompt.
For dependencies, you specify where the restored packages are placed during the restore operation using the --packages
argument. If not specified, the default NuGet package cache is used, which is found in the .nuget/packages
directory in the user’s home directory on all operating systems. For example, /home/user1 on Linux or C:1 on Windows.
For project-specific tooling, dotnet restore
first restores the package in which the tool is packed, and then proceeds to restore the tool’s dependencies as specified in its project file.
nuget.config differences
The behavior of the dotnet restore
command is affected by the settings in the nuget.config file, if present. For example, setting the globalPackagesFolder
in nuget.config places the restored NuGet packages in the specified folder. This is an alternative to specifying the --packages
option on the dotnet restore
command. For more information, see the nuget.config reference.
There are three specific settings that dotnet restore
ignores:
bindingRedirects
Binding redirects don’t work with
<PackageReference>
elements and .NET Core only supports<PackageReference>
elements for NuGet packages.solution
This setting is Visual Studio specific and doesn’t apply to .NET Core. .NET Core doesn’t use a
packages.config
file and instead uses<PackageReference>
elements for NuGet packages.trustedSigners
This setting isn’t applicable as NuGet doesn’t yet support cross-platform verification of trusted packages.
Implicit dotnet restore
Starting with .NET Core 2.0, dotnet restore
is run implicitly if necessary when you issue the following commands:
dotnet new
dotnet build
dotnet build-server
dotnet run
dotnet test
dotnet publish
dotnet pack
In most cases, you no longer need to explicitly use the dotnet restore
command.
Sometimes, it might be inconvenient to run dotnet restore
implicitly. For example, some automated systems, such as build systems, need to call dotnet restore
explicitly to control when the restore occurs so that they can control network usage. To prevent dotnet restore
from running implicitly, you can use the --no-restore
flag with any of these commands to disable implicit restore.
Arguments
ROOT
Optional path to the project file to restore.
Options
.NET Core 2.x
--configfile <FILE>
The NuGet configuration file (nuget.config) to use for the restore operation.
--disable-parallel
Disables restoring multiple projects in parallel.
--force
Forces all dependencies to be resolved even if the last restore was successful. Specifying this flag is the same as deleting the project.assets.json file.
-h|--help
Prints out a short help for the command.
--ignore-failed-sources
Only warn about failed sources if there are packages meeting the version requirement.
--no-cache
Specifies to not cache packages and HTTP requests.
--no-dependencies
When restoring a project with project-to-project (P2P) references, restores the root project and not the references.
--packages <PACKAGES_DIRECTORY>
Specifies the directory for restored packages.
-r|--runtime <RUNTIME_IDENTIFIER>
Specifies a runtime for the package restore. This is used to restore packages for runtimes not explicitly listed in the <RuntimeIdentifiers>
tag in the .csproj file. For a list of Runtime Identifiers (RIDs), see the RID catalog. Provide multiple RIDs by specifying this option multiple times.
-s|--source <SOURCE>
Specifies a NuGet package source to use during the restore operation. This setting overrides all of the sources specified in the nuget.config files. Multiple sources can be provided by specifying this option multiple times.
--verbosity <LEVEL>
Sets the verbosity level of the command. Allowed values are q[uiet]
, m[inimal]
, n[ormal]
, d[etailed]
, and diag[nostic]
. Default value is minimal
.
--interactive
Allows the command to stop and wait for user input or action (for example to complete authentication). Since .NET Core 2.1.400.
.NET Core 1.x
--configfile <FILE>
The NuGet configuration file (nuget.config) to use for the restore operation.
--disable-parallel
Disables restoring multiple projects in parallel.
-h|--help
Prints out a short help for the command.
--ignore-failed-sources
Only warn about failed sources if there are packages meeting the version requirement.
--no-cache
Specifies to not cache packages and HTTP requests.
--no-dependencies
When restoring a project with project-to-project (P2P) references, restores the root project and not the references.
--packages <PACKAGES_DIRECTORY>
Specifies the directory for restored packages.
-r|--runtime <RUNTIME_IDENTIFIER>
Specifies a runtime for the package restore. This is used to restore packages for runtimes not explicitly listed in the <RuntimeIdentifiers>
tag in the .csproj file. For a list of Runtime Identifiers (RIDs), see the RID catalog. Provide multiple RIDs by specifying this option multiple times.
-s|--source <SOURCE>
Specifies a NuGet package source to use during the restore operation. This overrides all of the sources specified in the nuget.config files, effectively reading the nuget.config file as if the <packageSource>
element was not there. Multiple sources can be provided by specifying this option multiple times.
--verbosity <LEVEL>
Sets the verbosity level of the command. Allowed values are q[uiet]
, m[inimal]
, n[ormal]
, d[etailed]
, and diag[nostic]
. The default is minimal
.
* * * * *
Examples
Restore dependencies and tools for the project in the current directory:
dotnet restore
Restore dependencies and tools for the app1
project found in the given path:
dotnet restore ~/projects/app1/app1.csproj
Restore the dependencies and tools for the project in the current directory using the file path provided as the source:
dotnet restore -s c:\packages\mypackages
Restore the dependencies and tools for the project in the current directory using the two file paths provided as sources:
dotnet restore -s c:\packages\mypackages -s c:\packages\myotherpackages
Restore dependencies and tools for the project in the current directory showing detailed output:
dotnet restore --verbosity detailed