NuGet.Packaging 6.12.1
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.Utils
Contains utilities used by ASP.NET Core Code Generation packages.
|
72 |
Microsoft.VisualStudio.Web.CodeGeneration.Utils
Contains utilities used by ASP.NET Core Code Generation packages.
|
84 |
Microsoft.VisualStudio.Web.CodeGenerators.Mvc
Code Generators for ASP.NET Core MVC. Contains code generators for MVC Controllers and Views.
|
69 |
NuGet.Packaging.Core
The (former home to) core data structures for NuGet.Packaging.
|
90 |
NuGet.Packaging.Core
The (former home to) core data structures for NuGet.Packaging. Contains only the type forwarders to the new assembly.
|
79 |
NuGet.Protocol
NuGet client library.
|
73 |
NuGet.Protocol
NuGet client library.
|
76 |
NuGet.Protocol
NuGet client library.
|
78 |
NuGet.Protocol
NuGet client library.
|
86 |
NuGet.Protocol
NuGet client library.
|
87 |
NuGet.Protocol
NuGet client library.
|
89 |
NuGet.Protocol
NuGet client library.
|
92 |
NuGet.Protocol
NuGet client library.
|
94 |
NuGet.Protocol
NuGet's implementation for interacting with feeds. Contains functionality for all feed types.
|
69 |
NuGet.Protocol
NuGet's implementation for interacting with feeds. Contains functionality for all feed types.
|
75 |
NuGet.Protocol
NuGet's implementation for interacting with feeds. Contains functionality for all feed types.
|
80 |
NuGet.Protocol
NuGet's implementation for interacting with feeds. Contains functionality for all feed types.
|
86 |
NuGet.Protocol
NuGet's implementation for interacting with feeds. Contains functionality for all feed types.
|
87 |
NuGet.Protocol
NuGet's implementation for interacting with feeds. Contains functionality for all feed types.
|
89 |
NuGet.Protocol
NuGet's implementation for interacting with feeds. Contains functionality for all feed types.
|
98 |
.NET Framework 4.7.2
- NuGet.Configuration (>= 6.12.1)
- System.Memory (>= 4.5.5)
- Newtonsoft.Json (>= 13.0.3)
- NuGet.Versioning (>= 6.12.1)
.NET Standard 2.0
- System.Security.Cryptography.Pkcs (>= 6.0.4)
- System.Formats.Asn1 (>= 8.0.1)
- Newtonsoft.Json (>= 13.0.3)
- NuGet.Versioning (>= 6.12.1)
- NuGet.Configuration (>= 6.12.1)
.NET 5.0
- System.Formats.Asn1 (>= 8.0.1)
- System.Security.Cryptography.Pkcs (>= 6.0.4)
- NuGet.Versioning (>= 6.12.1)
- NuGet.Configuration (>= 6.12.1)
- Newtonsoft.Json (>= 13.0.3)
Version | Downloads | Last updated |
---|---|---|
6.12.1 | 7 | 11/17/2024 |
6.12.0 | 6 | 11/17/2024 |
6.11.1 | 10 | 10/16/2024 |
6.11.0 | 12 | 08/14/2024 |
6.11.0-preview.2 | 15 | 06/10/2024 |
6.10.2 | 10 | 08/13/2024 |
6.10.1 | 9 | 07/01/2024 |
6.10.0 | 10 | 05/22/2024 |
6.9.1 | 11 | 03/08/2024 |
6.8.1 | 8 | 03/08/2024 |
6.8.0 | 22 | 11/18/2023 |
6.7.1 | 9 | 03/08/2024 |
6.7.0 | 32 | 09/04/2023 |
6.6.2 | 10 | 03/08/2024 |
6.6.1 | 21 | 06/14/2023 |
6.6.0 | 21 | 06/10/2023 |
6.6.0-preview.3 | 11 | 06/22/2023 |
6.5.1 | 10 | 06/22/2023 |
6.5.0 | 52 | 04/03/2023 |
6.4.3 | 9 | 03/08/2024 |
6.4.2 | 10 | 06/22/2023 |
6.4.0 | 22 | 12/08/2022 |
6.3.4 | 9 | 03/08/2024 |
6.3.3 | 14 | 06/22/2023 |
6.3.1 | 70 | 10/15/2022 |
6.3.0 | 45 | 09/08/2022 |
6.2.4 | 14 | 06/22/2023 |
6.2.2 | 65 | 10/15/2022 |
6.2.1 | 48 | 09/08/2022 |
6.2.0 | 46 | 09/09/2022 |
6.1.0 | 61 | 09/10/2022 |
6.0.6 | 10 | 03/05/2024 |
6.0.5 | 10 | 06/22/2023 |
6.0.3-rc.1 | 39 | 10/15/2022 |
6.0.2 | 22 | 09/09/2022 |
6.0.0 | 37 | 09/12/2022 |
6.0.0-preview.4.243 | 15 | 09/27/2022 |
6.0.0-preview.3 | 17 | 09/22/2022 |
5.11.6 | 9 | 03/08/2024 |
5.11.5 | 13 | 06/22/2023 |
5.11.3 | 82 | 10/15/2022 |
5.11.2 | 19 | 09/09/2022 |
5.11.0 | 20 | 06/27/2022 |
5.10.0 | 31 | 09/09/2022 |
5.10.0-preview.2.7185 | 75 | 09/23/2022 |
5.9.3 | 63 | 10/15/2022 |
5.9.2 | 30 | 09/09/2022 |
5.9.1 | 94 | 09/08/2022 |
5.9.0 | 70 | 09/11/2022 |
5.9.0-preview.2 | 18 | 09/23/2022 |
5.8.1 | 38 | 09/10/2022 |
5.8.0 | 80 | 09/10/2022 |
5.8.0-preview.3.6823 | 54 | 09/24/2022 |
5.8.0-preview.2.6776 | 60 | 09/25/2022 |
5.8.0-preview.1 | 75 | 09/21/2022 |
5.7.3-rtm.5 | 74 | 10/15/2022 |
5.7.2 | 32 | 09/13/2022 |
5.7.1 | 66 | 09/09/2022 |
5.7.0 | 43 | 09/10/2022 |
5.7.0-rtm.6702 | 20 | 09/22/2022 |
5.7.0-preview.3.6653 | 75 | 09/22/2022 |
5.7.0-preview.2.6618 | 40 | 09/22/2022 |
5.7.0-preview.1.6592 | 18 | 09/26/2022 |
5.6.0 | 26 | 06/27/2022 |
5.6.0-preview.3.6558 | 69 | 09/26/2022 |
5.6.0-preview.2.6489 | 100 | 09/22/2022 |
5.6.0-preview.1.6483 | 16 | 09/22/2022 |
5.5.1 | 31 | 09/11/2022 |
5.5.0 | 27 | 09/09/2022 |
5.5.0-preview.2.6382 | 34 | 09/23/2022 |
5.5.0-preview.1.6319 | 40 | 09/26/2022 |
5.4.0 | 41 | 09/11/2022 |
5.3.1 | 27 | 09/11/2022 |
5.3.0 | 25 | 09/12/2022 |
5.3.0-rtm.6192 | 20 | 09/24/2022 |
5.2.1 | 52 | 09/09/2022 |
5.2.0 | 48 | 09/14/2022 |
5.1.0 | 53 | 09/11/2022 |
5.1.0-preview2.5965 | 32 | 09/23/2022 |
5.0.2 | 37 | 09/09/2022 |
5.0.0 | 76 | 09/08/2022 |
5.0.0-rtm.5867 | 48 | 09/23/2022 |
5.0.0-rtm.5856 | 36 | 09/22/2022 |
5.0.0-preview3.5800 | 25 | 09/23/2022 |
5.0.0-preview2.5782 | 37 | 09/21/2022 |
4.9.6 | 17 | 10/15/2022 |
4.9.5 | 63 | 09/11/2022 |
4.9.4 | 28 | 06/27/2022 |
4.9.3 | 60 | 09/10/2022 |
4.9.2 | 69 | 09/14/2022 |
4.9.2-rtm.5706 | 18 | 09/26/2022 |
4.9.1 | 62 | 09/12/2022 |
4.9.0-rtm.5658 | 35 | 09/23/2022 |
4.8.2 | 30 | 09/09/2022 |
4.8.0 | 18 | 09/10/2022 |
4.8.0-rtm.5362 | 35 | 09/25/2022 |
4.8.0-preview3.5278 | 76 | 09/25/2022 |
4.8.0-preview1.5156 | 34 | 09/25/2022 |
4.7.3 | 29 | 09/09/2022 |
4.7.2 | 23 | 09/09/2022 |
4.7.0 | 26 | 09/10/2022 |
4.7.0-rtm.5148 | 76 | 09/21/2022 |
4.7.0-rtm.5104 | 32 | 10/15/2022 |
4.7.0-preview4.5065 | 20 | 09/25/2022 |
4.7.0-preview1-4986 | 38 | 09/22/2022 |
4.6.4 | 77 | 09/09/2022 |
4.6.3 | 27 | 09/09/2022 |
4.6.2 | 34 | 09/10/2022 |
4.6.1 | 53 | 09/08/2022 |
4.6.0 | 82 | 09/09/2022 |
4.6.0-rtm-4918 | 53 | 09/23/2022 |
4.6.0-rtm-4825 | 43 | 09/26/2022 |
4.6.0-rtm-4791 | 78 | 09/24/2022 |
4.5.3 | 40 | 09/11/2022 |
4.5.2 | 29 | 09/11/2022 |
4.5.0 | 37 | 09/08/2022 |
4.5.0-rtm-4651 | 19 | 09/21/2022 |
4.4.3 | 66 | 09/10/2022 |
4.4.2 | 94 | 09/09/2022 |
4.4.0 | 51 | 09/11/2022 |
4.4.0-preview3-4475 | 40 | 09/23/2022 |
4.3.1 | 46 | 09/09/2022 |
4.3.0 | 30 | 09/09/2022 |
4.3.0-rtm-4324 | 28 | 09/23/2022 |
4.3.0-preview4 | 20 | 09/26/2022 |
4.3.0-preview3-4168 | 20 | 09/22/2022 |
4.3.0-beta1-2418 | 52 | 09/22/2022 |
4.2.0 | 64 | 09/12/2022 |
4.1.0 | 87 | 09/08/2022 |
4.0.0 | 55 | 09/09/2022 |
4.0.0-rtm-2283 | 78 | 09/21/2022 |
4.0.0-rtm-2265 | 49 | 09/21/2022 |
4.0.0-rc3 | 22 | 09/09/2022 |
4.0.0-rc2 | 37 | 09/09/2022 |
4.0.0-rc-2048 | 94 | 09/23/2022 |
3.5.0 | 22 | 09/09/2022 |
3.5.0-rc1-final | 98 | 09/23/2022 |
3.5.0-beta2-1484 | 77 | 09/21/2022 |
3.5.0-beta-final | 33 | 09/25/2022 |
3.4.4-rtm-final | 98 | 09/22/2022 |
3.4.4-rc | 82 | 09/11/2022 |
3.4.3 | 47 | 09/13/2022 |
3.3.0 | 36 | 09/12/2022 |
3.2.0 | 31 | 09/09/2022 |
1.0.0-pre-20150220044603 | 81 | 09/25/2022 |
1.0.0-pre-20150128082032 | 29 | 09/24/2022 |
1.0.0-pre-20150128071326 | 65 | 09/23/2022 |
1.0.0-pre-20150127085617 | 39 | 09/22/2022 |
1.0.0-pre-20150127072405 | 26 | 10/15/2022 |
1.0.0-pre-20150120213149 | 63 | 09/25/2022 |
1.0.0-pre-20150120004808 | 80 | 09/25/2022 |
1.0.0-pre-20150115030027 | 20 | 09/25/2022 |
1.0.0-pre-20150109221036 | 16 | 10/15/2022 |
1.0.0-pre-20150108074227 | 97 | 09/22/2022 |
1.0.0-pre-20150108073125 | 41 | 09/22/2022 |
1.0.0-pre-20150108010629 | 73 | 09/23/2022 |
1.0.0-master-50072333 | 26 | 10/15/2022 |
1.0.0-master-50060114 | 46 | 09/23/2022 |
1.0.0-master-50050213 | 62 | 09/23/2022 |
1.0.0-master-43652058 | 78 | 09/24/2022 |
1.0.0-master-43642026 | 33 | 09/23/2022 |
1.0.0-master-43522145 | 13 | 09/23/2022 |
1.0.0-master-43500148 | 79 | 09/23/2022 |
1.0.0-master-43450313 | 34 | 09/24/2022 |
1.0.0-master-43440912 | 27 | 09/23/2022 |
1.0.0-master-43422320 | 76 | 09/22/2022 |
1.0.0-master-43421050 | 20 | 09/22/2022 |
1.0.0-master-43421019 | 18 | 09/24/2022 |
1.0.0-master-43402220 | 26 | 09/24/2022 |
1.0.0-master-43362332 | 81 | 09/25/2022 |
1.0.0-master-43362323 | 88 | 09/22/2022 |
1.0.0-master-43250244 | 54 | 09/26/2022 |
1.0.0-master-43250241 | 74 | 09/23/2022 |
1.0.0-master-43250237 | 46 | 09/22/2022 |
1.0.0-master-43250218 | 38 | 09/21/2022 |
1.0.0-juste-43290204 | 37 | 09/25/2022 |