NuGet is the official package manager used by the .NET platform. It automates the distribution, installation, and version management of libraries required by a project. Instead of manually downloading DLL files, developers reference packages that are automatically restored during the build process.
A NuGet package is a .nupkg file that
contains compiled assemblies, metadata, and dependency
information.
The .NET SDK provides the build tools. During a build, these tools automatically invoke NuGet to restore and manage required packages.
NuGet restore during build
When a C# project is built, the build process reads the project
file (.csproj) for all
<PackageReference> entries and performs a
NuGet restore operation.
During restore:
-
NuGet checks the local package cache.
-
If packages are missing, they are downloaded from configured package sources.
-
The packages are stored in the global package cache and used by the compiler.
If required packages are not restored successfully, the project cannot compile.
Commands such as the following automatically trigger this restore process:
dotnet build dotnet publish
Package sources
NuGet retrieves packages from configured sources, which may include:
-
Public repositories — for example, NuGet.org, which contains many open-source packages.
-
Private package servers — organization-hosted NuGet servers that contain internal libraries.
-
Local folders — used for offline development or local testing.
-
Cloud registries — such as Azure Artifacts or GitHub Packages.
NuGet reads package source configuration from the
NuGet.Config file, which may exist at machine,
user, or solution scope.
For more information, see: https://learn.microsoft.com/en-us/nuget/.


