- It is a single ZIP file with the
.nupkg
extension that contains compiled code, other files related to that code, and a descriptive manifest.
- NuGet supports private hosts alongside the public nuget.org host.
- NuGet enables you to host packages privately in the cloud (E.g. VSTS), on a private network, or even on local file system.
- You can add additional files such as a ReadMe that is displayed when the package is installed.
- When you include a file named
readme.txt
in the package root, Visual Studio displays its contents as plain text immediately after installing the package directly.
- It is not displayed for packages installed as dependencies.
- A package can serve to only pull other dependencies, without containing any code of its own.
- Such a package is a convenient way to deliver an SDK that's composed of multiple independent packages.
- A package may contain only symbol (
.pdb
) files to aid debugging.
- Create a manifest file (referred to as a
.nuspec
file) to describe the package's contents along with its identifier, version number, copyright info, MSBuild props and targets.
- Use the
nuget pack
command (or MSBuild pack target
) to put everything together into a .nupkg
file.
Package Targeting Compatibility
- A "compatible" package means that it contains assemblies built for at least one target .NET framework that's compatible with the consuming project's target framework.
- Developers can create packages that are specific to one framework or they can support a wider range of targets.
- Package developers who require APIs outside of .NET Standard, on the other hand, create separate assemblies for the different target frameworks they want to support and include all of those assemblies in the same package (which is called "multi-targeting").
- When a consumer installs such a package, NuGet extracts only those assemblies that are needed by the project.
- This minimizes the package's footprint in the final application and/or assemblies produced by that project.
- Targeting .NET Standard supersedes the previous approach of using various portable class library (PCL) targets.
.nuspec
File Structure
Required Properties
- The package identifier, which must be unique across the gallery that hosts the package.
- A specific version number in the form Major.Minor.Patch[-Suffix] where -Suffix identifies **pre-release versions.**
- The package title as it should appears on the host.
- Author and owner information.
- A long description of the package.