LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

dotnet-restore

Restore NuGet package dependencies for a .NET project

TLDR

Restore dependencies for the project in the current directory
$ dotnet restore
copy
Restore a specific project
$ dotnet restore [project.csproj]
copy
Restore from a specific NuGet source
$ dotnet restore --source [https://api.nuget.org/v3/index.json]
copy
Restore without using HTTP cache
$ dotnet restore --no-cache
copy
Restore for a specific runtime (RID)
$ dotnet restore --runtime [linux-x64]
copy
Restore in lock-file mode (fails if any package version drifts)
$ dotnet restore --locked-mode
copy
Restore with verbose logging
$ dotnet restore --verbosity detailed
copy

SYNOPSIS

dotnet restore [project|solution] [options]

DESCRIPTION

dotnet restore downloads and installs all NuGet package dependencies declared in a project, solution, or dotnet-tools.json. It reads PackageReference entries from .csproj/.fsproj/.vbproj files, queries the configured NuGet sources, and writes restored assets to obj/project.assets.json.Other commands like dotnet build and dotnet run trigger an implicit restore by default, so explicit invocation is mainly useful in CI pipelines (where you want to cache the restore step), when troubleshooting package resolution, or when --no-restore is being used downstream.

PARAMETERS

-s, --source SOURCE

NuGet package source to use during restore (overrides nuget.config).
--packages DIR
Directory in which to install the restored packages (default: ~/.nuget/packages).
--no-cache
Don't cache HTTP requests; always re-fetch from the source.
--no-dependencies
Restore only the root project, ignoring project-to-project references.
--force
Force all dependencies to be re-resolved even if a cached lock exists.
--locked-mode
Don't allow updates to packages.lock.json — fail if it would change.
--use-lock-file
Generate or update packages.lock.json.
--runtime RID
Target a specific runtime identifier (e.g. linux-x64, win-x86).
--configfile FILE
NuGet config file to use instead of the default chain.
--disable-parallel
Disable parallel downloads.
-v, --verbosity LEVEL
Verbosity: q[uiet], m[inimal], n[ormal], d[etailed], diag[nostic].
-?, -h, --help
Display help.

CAVEATS

Restore obeys the standard NuGet config chain: machine-wide, user, and per-directory NuGet.config files. --source replaces (not adds to) configured sources. Setting --locked-mode without an existing packages.lock.json fails immediately.

SEE ALSO

Copied to clipboard
Kai