Introduction
A .nupkg file is a package for NuGet,
the package manager for .NET. It holds a library’s compiled assemblies, often built
for several versions of .NET, with a manifest naming the package, its version and the
packages it depends on. Projects list the packages they use, and the .NET tools download
them from nuget.org or another feed when the project is restored. Packages of debugging
symbols use the same format with the extension .snupkg.
Structure
A NuGet package is a ZIP archive laid out as an Open
Packaging Conventions package. At its root is the .nuspec manifest, an XML
file with the package’s ID, version, authors, description, licence and dependencies.
Assemblies go in lib/, in a folder per target framework such as
lib/net8.0/ or lib/netstandard2.0/. Other folders hold
build files, content and native runtimes. A signed package adds a
.signature.p7s file. Every element and attribute of the manifest is on
the .nuspec manifest page.
Newtonsoft.Json.13.0.3.nupkg
├── Newtonsoft.Json.nuspec
├── lib/
│ ├── net45/Newtonsoft.Json.dll
│ └── netstandard2.0/Newtonsoft.Json.dll
├── [Content_Types].xml
├── _rels/.rels
├── package/services/metadata/core-properties/….psmdcp
└── .signature.p7s
Not described
Known, not yet covered
- Reference: the OPC parts of a package, the
.signature.p7ssignature, the version range syntax, target framework monikers, package types and the folder conventions, all in NuGet’s documentation; see nuspec. - Viewer: the explorer opens a
.nupkgas the ZIP archive it is, and reads a.nuspecand anuget.configfile; it does not read the package’s OPC parts, its signature or the files inside as one NuGet package.
Also used for
- NuGet configuration – The package sources, credentials, mappings and settings NuGet reads, as XML.
- NuGet package specification – The XML manifest of a NuGet package: its identity, dependencies and files.
Links
Software
- .NET SDK – its
dotnet packanddotnet add packagemake and use packages (Windows, macOS, Linux) - Visual Studio – Microsoft’s IDE, with its NuGet package manager (Windows)
- nuget.exe – the NuGet command line (Windows)
- NuGet Package Explorer – opens, inspects and edits packages (Windows)
Reference
- .nuspec reference – Microsoft’s reference for the manifest