A system for developers to produce, exchange, and consume valuable code is a vital feature of any modern development environment. Such code is frequently packaged as “packages” that include compiled code (as DLLs) and other content required by the projects that consume these packages.
NuGet is the Microsoft-supported system for exchanging code for .NET (including.NET Core), and it defines how packages for.NET are generated, hosted, and consumed and provides tools for each of those functions.
A NuGet package is a single ZIP file with the .nupkg extension containing built-in code (DLLs), related files, and a thorough manifest that includes information like the product’s version number. Packages are created by developers who want to share their code and then upload it to a public or private server. Package consumers download packages from relevant servers, incorporate them in their projects, and then use the packages’ functionality in their code. NuGet then handles the intermediate data.
Because NuGet supports private sites and the public nuget.org host, you may use NuGet packages to share code exclusive to an enterprise or a workgroup. You may also factor your code with NuGet packages so that it can only be utilized in your apps. In conclusion, a NuGet package is a shareable unit of code that does not imply or need any specific sharing method.
Feature Comparisons
Feature | dotnet CLI | nuget CLI (Windows) | nuget CLI (Mono) | Visual Studio (Windows) | Visual Studio for Mac |
---|---|---|---|---|---|
Search packages | ✔ | ✔ | ✔ | ✔ | |
Install/uninstall packages | ✔ | ✔(1) | ✔ | ✔ | ✔ |
Update packages | ✔ | ✔ | ✔ | ✔ | |
Restore packages | ✔ | ✔ | ✔(2) | ✔ | ✔ |
Manage package feeds (sources) | ✔ | ✔ | ✔ | ✔ | |
Manage packages on a feed | ✔ | ✔ | ✔ | ||
Set API keys for feeds | ✔ | ✔ | |||
Create packages(3) | ✔ | ✔ | ✔(4) | ✔ | |
Publish packages | ✔ | ✔ | ✔ | ✔ | |
Replicate packages | ✔ | ✔ | |||
Manage global-package and cache folders | ✔ | ✔ | ✔ | ||
Manage NuGet configuration | ✔ | ✔ |
(1) Does not alter project files; instead, use dotnet.exe.
(2) Only works with the packages “.config” file, not solution (.sln) files.
(3) Because sophisticated package features aren’t reflected in the Visual Studio UI tools, they can only be accessed via the CLI.
(4) It only works with “.nuspec” files, not project files.