Skip to content

Latest commit

 

History

History
160 lines (102 loc) · 8.87 KB

File metadata and controls

160 lines (102 loc) · 8.87 KB
title NuGet Client SDK
description The API is evolving and not yet documented, but examples are available on Dave Glick's blog.
author JonDouglas
ms.author jodou
ms.date 01/09/2018
ms.topic article

NuGet Client SDK

The NuGet Client SDK refers to a group of NuGet packages:

  • NuGet.Indexing - NuGet's indexing library for the Visual Studio client search functionality.
  • NuGet.Commands - Complete commands common to command-line and GUI NuGet clients.
  • NuGet.Common - Common utilities and interfaces for all NuGet libraries.
  • NuGet.Configuration - NuGet's configuration settings implementation.
  • NuGet.Credentials - NuGet client's authentication models.
  • NuGet.DependencyResolver.Core - NuGet's PackageReference dependency resolver implementation.
  • NuGet.Frameworks - NuGet's understanding of target frameworks.
  • NuGet.LibraryModel - NuGet's types and interfaces for understanding dependencies.
  • NuGet.Localization - NuGet localization package.
  • NuGet.PackageManagement - NuGet Package Management functionality for Visual Studio installation flow.
  • NuGet.Packaging - Provides a set of APIs to interact with .nupkg and .nuspec files from a stream. NuGet.Protocol depends on this package.
  • NuGet.ProjectModel - NuGet's core types and interfaces for PackageReference-based restore, such as lock files, assets file and internal restore models.
  • NuGet.Protocol - Provides a set of APIs interact with HTTP and file-based NuGet feeds.
  • NuGet.Resolver - NuGet's dependency resolver for packages.config based projects.
  • NuGet.Versioning - NuGet's implementation of Semantic Versioning.

You can find the source code for these packages in the NuGet/NuGet.Client GitHub repository.

Note

For documentation on the NuGet server protocol, please refer to the NuGet Server API.

Support policy

The most recent version of NuGet Client SDK is fully supported and can be relied on for bug fixes, updates, and enhancements.

The recommendation is to use the latest versions of NuGet Client SDK packages, and to examine your project for dependencies on deprecated NuGet Client SDK packages.

Patch Releases

Patched versions of NuGet Client SDK will be released exclusively when critical bugs or security fixes are required for a long-term support (LTS) version of Visual Studio or .NET SDK.

All security bugs should be reported to the Microsoft Security Response Center (MSRC) at MSRC's report page. Also, see the security policy in the NuGet.Client repo.

We do not guarantee API stability, as our team's responsibility is tooling, not libraries. See the NuGet SDK documentation in the NuGet.Client repo for more information.

Package Deprecation

Out-of-support NuGet Client SDK packages that are not tied to an LTS version of either Visual Studio or .NET will be deprecated on nuget.org.

NuGet's package maintenance approach will align with the .NET Package Maintenance (deprecation) guidance.

NuGet.Protocol

Install the NuGet.Protocol package to interact with HTTP and folder-based NuGet package feeds:

dotnet package add NuGet.Protocol

You can find the source code for these examples on the NuGet.Protocol.Samples project on GitHub.

Tip

Repository.Factory is defined in the NuGet.Protocol.Core.Types namespace, and the GetCoreV3 method is an extension method defined in the NuGet.Protocol namespace. Therefore, you will need to add using statements for both namespaces.

List package versions

Find all versions of Newtonsoft.Json using the NuGet V3 Package Content API:

[!code-csharpListPackageVersions]

Download a package

Download Newtonsoft.Json v12.0.1 using the NuGet V3 Package Content API:

[!code-csharpDownloadPackage]

Get package metadata

Get the metadata for the "Newtonsoft.Json" package using the NuGet V3 Package Metadata API:

[!code-csharpGetPackageMetadata]

Search packages

Search for "json" packages using the NuGet V3 Search API:

[!code-csharpSearchPackages]

Push a package

Push a package using the NuGet V3 Push and Delete API:

[!code-csharpPushPackage]

Delete a package

Delete a package using the NuGet V3 Push and Delete API:

Note

NuGet servers are free to interpret a package delete request as a "hard delete", "soft delete", or "unlist". For example, nuget.org interprets the package delete request as an "unlist". For more information about this practice, see the Deleting Packages policy.

[!code-csharpDeletePackage]

Work with authenticated feeds

Use NuGet.Protocol to work with authenticated feeds.

[!code-csharpAuthenticatedFeed]

NuGet.Packaging

Install the NuGet.Packaging package to interact with .nupkg and .nuspec files from a stream:

dotnet package add NuGet.Packaging

Create a package

Create a package, set metadata, and add dependencies using NuGet.Packaging.

Important

It is strongly recommended that NuGet packages are created using the official NuGet tooling and not using 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).

[!code-csharpCreatePackage]

Read a package

Read a package from a file stream using NuGet.Packaging.

[!code-csharpReadPackage]

Third-party documentation

You can find examples and documentation for some of the API in the following blog series by Dave Glick, published 2016:

Note

These blog posts were written shortly after the 3.4.3 version of the NuGet client SDK packages were released. Newer versions of the packages may be incompatible with the information in the blog posts.

Martin Björkström did a follow-up blog post to Dave Glick's blog series where he introduces a different approach on using the NuGet Client SDK to install NuGet packages: