Artifactory Support for NuGet Repositories
Since version 2.5, Artifactory provides complete support for NuGet repositories on top of Artifactory's existing support for advanced artifact management.
Artifactory support for NuGet provides:
- The ability to provision NuGet packages from Artifactory to NuGet clients from all repository types
- Metadata calculation for NuGet packages hosted in Artifactory's local repositories
- The ability to define proxies and caches to access Remote NuGet repositories
- Multiple NuGet repository aggregation through virtual repositories
- APIs to deploy or remove packages that are compatible with NuGet Package Manager Visual Studio extension and the NuGet Command Line Tool
Configuring Artifactory to Work With NuGet Repositories
To enable NuGet package metadata calculation on local repositories, select the "Packages" tab and check "Enable NuGet Support".
Local Repository Layout
To support a more manageable repository layout, you may store NuGet packages inside folders that correspond to the package structure.
Artifactory will find your packages by performing a property search so the folder hierarchy does not impact performance.
To use a hierarchical layout for your repository you should define a Custom Layout. This way, different maintenance features like Version Cleanup will work correctly with NuGet packages.
Below is an example of a Custom Layout named
In this example, the three fields that are mandatory for module identification are:
- Organization = "orgPath"
- Module = "module"
- Base Revision ("baseRev") is not a part of the layout hierarchy in this example, but it is included here as one of the required fields.
You can configure this Custom Layout as displayed in the image above, or simply copy the below code snippet into the relevant section in your Artifactory Central Configuration (Admin tab > Advanced > Config Descriptor):
Since the package layout is in a corresponding folder hierarchy, the Artifactory Version Cleanup tool correctly detects previously installed versions.
When working with remote NuGet repositories, your Artifactory configuration depends on how the remote repositories are set up.
Different NuGet server implementations may provide package resources on different paths, therefore the feed and download resource locations in Artifactory are customizable when proxying a remote NuGet repository.
Here are some examples:
A Virtual Repository defined in Artifactory aggregates packages from both local and remote repositories.
This allows you to access both locally hosted NuGet packages and remote proxied NuGet libraries from a single URL defined for the virtual repository.
To define a virtual repository for NuGet, check "Enable NuGet Support" in the "Packages" tab.
How to Access NuGet Repositories from Visual Studio Using Artifactory
Artifactory exposes its NuGet resources via the REST API at the following URL:
This URL handles all NuGet related requests (search, download, upload, delete) and supports both V1 and V2 requests.
To configure the NuGet Visual Studio Extension to use Artifactory, check the corresponding repositories in the "Options" window:
To use the Nuget Command Line tool:
- Download NuGet.exe
- Place it in a well known location in your file system such as c:\utils
- Make sure that NuGet.exe is in your path
For complete information on how to use the NuGet Command Line tool please refer to the NuGet Docs Command Line Reference.
First configure a new source URL pointing to Artifactory:
NuGet API Key Authentication
NuGet tools require that sensitive operations such as push and delete are authenticated with the server using an
API key. The API key you should use is in the form of
username:password, where the password can be either clear-text or encrypted.
Set your API key using the NuGet Command Line Interface:
Now you can perform operations against the newly added server. For example:
Viewing Individual NuGet Package Information Within the Artifactory UI
You can view all the metadata annotating a NuGet package by choosing the NuPkg file in Artifactory's tree browser and selecting the
NuPkg Info tab: