NuGet.Packaging 6.11.0-preview.2
Nuget.Packaging
NuGet.Packaging is a NuGet client SDK library that provides a set of APIs to interact with .nupkg
and .nuspec
files from a stream. It provides a way for developers to create and read packages and work with the package metadata.
Usage
It is strongly recommended that NuGet packages are created using the official NuGet tooling and instead of this low-level API. There are a variety of characteristics important for a well-formed package and the latest version of tooling helps incorporate these best practices.
For more information about creating NuGet packages, see the overview of the package creation workflow and the documentation for official pack tooling (for example, using the dotnet CLI).
Examples
Create a package
Create a package, set metadata, and add dependencies.
PackageBuilder builder = new PackageBuilder();
builder.Id = "MyPackage";
builder.Version = new NuGetVersion("1.0.0-beta");
builder.Description = "My package created from the API.";
builder.Authors.Add("Sample author");
builder.DependencyGroups.Add(new PackageDependencyGroup(
targetFramework: NuGetFramework.Parse("netstandard1.4"),
packages: new[]
{
new PackageDependency("Newtonsoft.Json", VersionRange.Parse("10.0.1"))
}));
using FileStream outputStream = new FileStream("MyPackage.nupkg", FileMode.Create);
builder.Save(outputStream);
Console.WriteLine($"Saved a package to {outputStream.Name}");
Read a package
Read a package from a file.
using FileStream inputStream = new FileStream("MyPackage.nupkg", FileMode.Open);
using PackageArchiveReader reader = new PackageArchiveReader(inputStream);
NuspecReader nuspec = reader.NuspecReader;
Console.WriteLine($"ID: {nuspec.GetId()}");
Console.WriteLine($"Version: {nuspec.GetVersion()}");
Console.WriteLine($"Description: {nuspec.GetDescription()}");
Console.WriteLine($"Authors: {nuspec.GetAuthors()}");
Console.WriteLine("Dependencies:");
foreach (PackageDependencyGroup dependencyGroup in nuspec.GetDependencyGroups())
{
Console.WriteLine($" - {dependencyGroup.TargetFramework.GetShortFolderName()}");
foreach (var dependency in dependencyGroup.Packages)
{
Console.WriteLine($" > {dependency.Id} {dependency.VersionRange}");
}
}
Additional documentation
More information about the NuGet.Packaging library can be found on the official Microsoft documentation page and NuGet API docs.
Showing the top 20 packages that depend on NuGet.Packaging.
Packages | Downloads |
---|---|
Microsoft.VisualStudio.Web.CodeGeneration.Templating
Contains Razor based templating host used by ASP.NET Core Code Generators.
|
53 |
Microsoft.DotNet.Cli.Utils
Package Description
|
50 |
NuGet.Protocol.Core.v3
NuGet Protocol for 3.1.0 servers
|
50 |
Microsoft.VisualStudio.Web.CodeGeneration.Templating
Contains Razor based templating host used by ASP.NET Core Code Generators.
|
50 |
NuGet.Repositories
NuGet v3 core library.
|
49 |
Microsoft.VisualStudio.Web.CodeGeneration.Templating
Contains Razor based templating host used by ASP.NET Core Code Generators.
|
49 |
Microsoft.VisualStudio.Web.CodeGeneration.Templating
Contains Razor based templating host used by ASP.NET Core Code Generators.
|
48 |
NuGet.Protocol.Core.Types
NuGet's protocol-level base types used for connecting to API v2 and API v3 repositories.
|
47 |
Microsoft.VisualStudio.Web.CodeGeneration.Design
Code Generation tool for ASP.NET Core. Contains the dotnet-aspnet-codegenerator command used for generating controllers and views.
|
47 |
Microsoft.VisualStudio.Web.CodeGeneration.Templating
Contains Razor based templating host used by ASP.NET Core Code Generators.
|
47 |
NuGet.Repositories
NuGet v3 core library.
|
47 |
Microsoft.DotNet.ProjectModel
Types to model a .NET Project
|
46 |
NuGet.Protocol.Core.Types
NuGet's protocol-level base types used for connecting to API v2 and API v3 repositories.
|
46 |
Microsoft.VisualStudio.Web.CodeGeneration.Templating
Contains Razor based templating host used by ASP.NET Core Code Generators.
|
46 |
Microsoft.DotNet.ProjectModel
Types to model a .NET Project
|
45 |
NuGet.Repositories
NuGet v3 core library.
|
45 |
NuGet.Packaging.Core
The (former home to) core data structures for NuGet.Packaging. Contains only the type forwarders to the new assembly.
|
45 |
NuGet.Protocol.Core.Types
NuGet's protocol-level base types used for connecting to API v2 and API v3 repositories.
|
45 |
.NET Framework 4.7.2
- NuGet.Configuration (>= 6.11.0-preview.2)
- NuGet.Versioning (>= 6.11.0-preview.2)
- Newtonsoft.Json (>= 13.0.3)
.NET 5.0
- NuGet.Configuration (>= 6.11.0-preview.2)
- NuGet.Versioning (>= 6.11.0-preview.2)
- Newtonsoft.Json (>= 13.0.3)
- System.Security.Cryptography.Pkcs (>= 6.0.4)
.NET Standard 2.0
- NuGet.Configuration (>= 6.11.0-preview.2)
- NuGet.Versioning (>= 6.11.0-preview.2)
- Newtonsoft.Json (>= 13.0.3)
- System.Security.Cryptography.Pkcs (>= 6.0.4)
Version | Downloads | Last updated |
---|---|---|
6.13.2 | 16 | 03/01/2025 |
6.13.1 | 11 | 02/15/2025 |
6.12.1 | 24 | 11/13/2024 |
6.12.0 | 18 | 11/13/2024 |
6.11.1 | 24 | 10/07/2024 |
6.11.0 | 23 | 08/15/2024 |
6.11.0-preview.2 | 23 | 06/09/2024 |
6.10.2 | 21 | 08/15/2024 |
6.10.1 | 32 | 06/27/2024 |
6.10.0 | 31 | 06/09/2024 |
6.9.1 | 28 | 02/29/2024 |
6.8.1 | 28 | 02/29/2024 |
6.8.0 | 37 | 11/23/2023 |
6.7.1 | 29 | 02/29/2024 |
6.7.0 | 31 | 08/15/2023 |
6.6.2 | 30 | 02/29/2024 |
6.6.1 | 35 | 08/06/2023 |
6.6.0 | 37 | 08/15/2023 |
6.6.0-preview.3 | 35 | 09/19/2023 |
6.5.1 | 37 | 09/24/2023 |
6.5.0 | 30 | 08/07/2023 |
6.4.3 | 26 | 02/29/2024 |
6.4.2 | 29 | 08/09/2023 |
6.4.0 | 34 | 08/08/2023 |
6.3.4 | 35 | 02/29/2024 |
6.3.3 | 35 | 08/08/2023 |
6.3.1 | 29 | 08/22/2023 |
6.2.4 | 37 | 08/06/2023 |
6.2.2 | 37 | 10/04/2023 |
6.1.0 | 32 | 08/06/2023 |
6.0.6 | 34 | 02/29/2024 |
6.0.5 | 35 | 09/23/2023 |
6.0.3-rc.1 | 33 | 09/23/2023 |
6.0.2 | 30 | 08/24/2023 |
5.11.6 | 33 | 02/29/2024 |
5.11.5 | 32 | 08/11/2023 |
5.11.3 | 26 | 08/11/2023 |
5.10.0 | 32 | 07/24/2023 |
5.9.3 | 27 | 08/15/2023 |
5.8.1 | 29 | 08/18/2023 |
5.7.3-rtm.5 | 35 | 08/06/2023 |
5.7.2 | 35 | 08/02/2023 |
5.6.0 | 29 | 09/25/2023 |
5.5.1 | 27 | 08/08/2023 |
5.4.0 | 37 | 09/23/2023 |
5.3.1 | 32 | 08/05/2023 |
5.2.1 | 37 | 08/11/2023 |
5.1.0 | 35 | 08/04/2023 |
5.0.2 | 27 | 08/25/2023 |
4.9.6 | 36 | 08/07/2023 |
4.8.2 | 34 | 08/07/2023 |
4.7.3 | 38 | 08/12/2023 |
4.6.4 | 27 | 08/05/2023 |
4.5.3 | 33 | 08/14/2023 |
4.4.3 | 32 | 08/15/2023 |
4.3.1 | 37 | 08/26/2023 |
4.2.0 | 31 | 08/08/2023 |
4.1.0 | 27 | 08/11/2023 |
4.0.0 | 31 | 08/11/2023 |
3.5.0 | 29 | 07/17/2023 |
3.4.4-rtm-final | 36 | 08/18/2023 |
3.4.3 | 29 | 08/14/2023 |
3.3.0 | 32 | 08/12/2023 |
3.2.0 | 29 | 08/23/2023 |