NuGet is the Microsoft-supported mechanism for sharing code on the .NET platform. Microsoft’s documentation defines it directly: “For .NET (including .NET Core), the Microsoft-supported mechanism for sharing code is NuGet, which defines how packages for .NET are created, hosted, and consumed, and provides the tools for each of those roles” (https://learn.microsoft.com/en-us/nuget/what-is-nuget).
A NuGet package is, in the documentation’s words, “a single ZIP file with the .nupkg extension that contains compiled code (DLLs), other files related to that code, and a descriptive manifest that includes information like the package’s version number” (https://learn.microsoft.com/en-us/nuget/what-is-nuget). Developers publish packages to a host and consumers pull them into their projects, with NuGet handling the intermediate details.
At the center of the ecosystem is the public registry. The documentation explains that “in its role as a public host, NuGet itself maintains the central repository of over 100,000 unique packages at nuget.org,” packages that “are employed by millions of .NET/.NET Core developers every day” (https://learn.microsoft.com/en-us/nuget/what-is-nuget). NuGet also supports private hosts on a network or local file system for sharing code within an organization.
Much of NuGet’s value lies in managing dependencies. The documentation notes that “much of what NuGet does is managing that dependency tree or graph on behalf of a project,” so that if your packages “themselves consume other packages (which can, in turn, consume still others), NuGet takes care of all those down-level dependencies” (https://learn.microsoft.com/en-us/nuget/what-is-nuget). Rather than storing package binaries in source control, NuGet keeps a reference list and restores the packages on demand, the same restore-from-a-manifest pattern used by tools like npm in other ecosystems.