This article applies to: ✔️ .NET Core 3.1 SDK and later versions
dotnet restore - Restores the dependencies and tools of a project.
dotnet restore [<ROOT>] [--configfile <FILE>] [--disable-parallel] [-f|--force] [--force-evaluate] [--ignore-failed-sources] [--interactive] [--lock-file-path <LOCK_FILE_PATH>] [--locked-mode] [--no-cache] [--no-dependencies] [--packages <PACKAGES_DIRECTORY>] [-r|--runtime <RUNTIME_IDENTIFIER>] [-s|--source <SOURCE>] [--use-lock-file] [-v|--verbosity <LEVEL>] dotnet restore -h|--help
dotnet restore command uses NuGet to restore dependencies as well as project-specific tools that are specified in the project file. In most cases, you don't need to explicitly use the
dotnet restore command, since a NuGet restore is run implicitly if necessary when you run the following commands:
Sometimes, it might be inconvenient to run the implicit NuGet restore with these commands. 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 the implicit NuGet restore, you can use the
--no-restore flag with any of these commands to disable implicit restore.
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 .NET SDK is installed. To specify additional feeds, do one of the following:
- Create your own nuget.config file in the project directory. For more information, see Common NuGet configurations and nuget.config differences later in this article.
dotnet nugetcommands such as
dotnet nuget add source.
You can override the nuget.config feeds with the
For information about how to use authenticated feeds, see Consuming packages from authenticated feeds.
Global packages folder
For dependencies, you can 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:\Users\user1 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.
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:
Binding redirects don't work with
<PackageReference>elements and .NET only supports
<PackageReference>elements for NuGet packages.
This setting is Visual Studio specific and doesn't apply to .NET. .NET doesn't use a
packages.configfile and instead uses
<PackageReference>elements for NuGet packages.
Support for cross-platform package signature verification was added in the .NET 5.0.100 SDK.
Workload manifest downloads
When you run this command, it initiates an asynchronous background download of advertising manifests for workloads. If the download is still running when this command finishes, the download is stopped. For more information, see Advertising manifests.
Optional path to the project file to restore.
The NuGet configuration file (nuget.config) to use. If specified, only the settings from this file will be used. If not specified, the hierarchy of configuration files from the current directory will be used. For more information, see Common NuGet Configurations.
Disables restoring multiple projects in parallel.
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.
Forces restore to reevaluate all dependencies even if a lock file already exists.
Prints out a description of how to use the command.
Only warn about failed sources if there are packages meeting the version requirement.
Allows the command to stop and wait for user input or action. For example, to complete authentication.
Output location where project lock file is written. By default, this is PROJECT_ROOT\packages.lock.json.
Don't allow updating project lock file.
Specifies to not cache HTTP requests.
When restoring a project with project-to-project (P2P) references, restores the root project and not the references.
Specifies the directory for restored packages.
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.
Specifies the URI of the 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.
Enables project lock file to be generated and used with restore.
Sets the verbosity level of the command. Allowed values are
diag[nostic]. The default is
minimal. For more information, see LoggerVerbosity.
Restore dependencies and tools for the project in the current directory:
Restore dependencies and tools for the
app1project 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
Submit and view feedback for