← All notes

NuGet Package Restore installs a .NET project's dependencies with dotnet restore, nuget restore or msbuild

Answer: Run dotnet restore, nuget restore or msbuild -t:restore; dotnet build and dotnet run restore automatically. Package Restore restores all dependencies listed in a project file (<PackageReference>) or a packages.config file, so package binaries need not be stored in source control.

Commands

dotnet restore
dotnet add package Newtonsoft.Json   # adds the reference and runs restore
nuget restore MySolution.sln
msbuild -t:restore
msbuild -restore                     # restore then build in one step
nuget locals http-cache -clear

How restore resolves packages

  1. It installs the direct dependencies of a project, then their dependencies throughout the entire dependency graph.
  2. For a missing package, NuGet first tries the local global packages or HTTP cache folders.
  3. Then it tries to download from all configured package sources. Source order is ignored: the package comes from whichever source responds first.
  4. If restore fails, NuGet reports a failure for only the last source, after checking all sources.

Configuration

Why it matters

Package Restore promotes a cleaner development environment and reduces repository size, because a project's dependencies are available without storing them in source control.

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Microsoft Learn (NuGet docs), Restore packages with NuGet Package Restore; NuGet/docs.microsoft.com-nuget (GitHub), Package-Restore.md (source page). MIT (https://raw.githubusercontent.com/NuGet/docs.microsoft.com-nuget/main/LICENSE). Copyright .NET Foundation. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Microsoft Learn (NuGet docs), Restore packages with NuGet Package Restore; NuGet/docs.microsoft.com-nuget (GitHub), Package-Restore.md (source page). MIT (https://raw.githubusercontent.com/NuGet/docs.microsoft.com-nuget/main/LICENSE). Copyright .NET Foundation.

Cite this

Permanent ID: iil:note:5rt5tdyc

iinventedlight. 2026. "NuGet Package Restore installs a .NET project's dependencies with dotnet restore, nuget restore or msbuild." iinventedlight Library, iil:note:5rt5tdyc, version of 2026-11-18. https://iinventedlight.com/library/notes/nuget-package-restore/. License: CC-BY-4.0.

@misc{iil_note_5rt5tdyc,
  author = {{iinventedlight}},
  title = {{NuGet Package Restore installs a .NET project's dependencies with dotnet restore, nuget restore or msbuild}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-18},
  url = {https://iinventedlight.com/library/notes/nuget-package-restore/},
  note = {Permanent ID iil:note:5rt5tdyc. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/nuget-package-restore.md.