dotnet-restore
Restore NuGet packages for a project
TLDR
Restore dependencies for a .NET project or solution in the current directory
Restore dependencies for a .NET project or solution in a specific location
Restore dependencies without caching the HTTP requests
Force all dependencies to be resolved even if the last restore was successful
Restore dependencies using package source failures as warnings
Restore dependencies with a specific verbosity level
SYNOPSIS
dotnet restore [PATH_TO_PROJECT_OR_SOLUTION] [options]
PARAMETERS
--configfile, -c <FILE>
Path to alternate NuGet.Config file
--disable-parallel
Disable restoring multiple projects in parallel
--force
Force complete rebuild of dependencies
--force-evaluate
Re-evaluate all dependencies even if lock file exists
--ignore-failed-sources
Skip sources that fail (treat as empty)
--interactive
Allow user input for authentication or prompts
--keep-duplicate-packages
Preserve duplicate packages in graph
--locked-mode
Require exact match to lock file; fail if missing
--lock-file-path <PATH>
Path to custom packages.lock.json
--no-cache
Skip using cache; download all packages
--packages <DIR>
Directory to place restored packages
--runtime <RID>
Restore packages for specific runtime identifier
--source, -s <SOURCE>
Add package source (URL); supports multiple
--use-lock-file
Create or use packages.lock.json for determinism
--verbosity <LEVEL>
Set output verbosity: quiet|minimal|normal|detailed|diagnostic
DESCRIPTION
dotnet restore is a core command in the .NET SDK that restores NuGet package dependencies and project-specific tools for .NET projects and solutions. It analyzes the *.csproj, *.fsproj, or *.sln files to identify required packages, downloads them from configured NuGet sources (like nuget.org), and caches them in the global packages folder (typically $HOME/.nuget/packages on Linux) or a custom directory.
The restore process generates an obj/project.assets.json file containing the resolved dependency graph, which is used by dotnet build, dotnet run, and other commands. It supports parallel restores by default for speed, handles transitive dependencies, and respects packages.lock.json files for reproducible builds.
Essential after cloning repositories or modifying dependencies, it ensures local availability without network access during builds. On Linux, it integrates seamlessly with distributions packaging the .NET SDK via apt, yum, etc. Customizable via NuGet.Config files for sources, credentials, and proxies.
Unlike legacy MSBuild /t:Restore, it's optimized for modern .NET workflows and cross-platform use.
CAVEATS
Requires .NET SDK 2.0+ installed and in PATH. May prompt for credentials on private feeds. Global packages folder permissions needed on Linux.
PATH ARGUMENT
Optional path to *.csproj, *.sln, or directory; defaults to current directory.
Supports glob patterns for multiple projects.
EXIT CODES
0: success
1+: failure (e.g., unresolved deps, network issues)
HISTORY
Introduced in .NET Core SDK 1.0 (2016) as replacement for nuget restore. Enhanced in .NET 5+ for speed, Central Package Management, and lock file support. Now standard in .NET 8+.
SEE ALSO
dotnet(1), dotnet-build(1), nuget(1)


