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
- Debugging NuGet packages directly using Artifactory as a Microsoft Symbol Server
NuGet metadata is automatically calculated and updated when adding, removing, copying or moving NuGet packages. The calculation is only invoked after a package-related action is completed.
It is asynchronous and its performance depends on the overall system load, therefore it may sometimes take up to 30 seconds to complete.
You can also invoke metadata calculation on the entire repository by selecting "Reindex Packages".
To create a local repository for which Artifactory will calculate NuGet package metadata, set NuGet to be the Package Type.
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.
Placing packages to match your repository layout
Defining a Custom Layout for your repository does not force you to place your packages in the corresponding structure, however it is recommended to do so since it allows Artifactory to perform different maintenance tasks such as Version Cleanup automatically.
It is up to the developer to correctly deploy packages into the corresponding folder. From NuGet 2.5 you can push packages into a folder source as follows:
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 Global Configuration Descriptor:
Since the package layout is in a corresponding folder hierarchy, the Artifactory Version Cleanup tool correctly detects previously installed versions.
Publishing to a Local Repository
When a NuGet repository is selected in the Artifacts module Tree Browser, click Set Me Up to display the code snippets you can use to configure Visual Studio or your NuGet client to use the selected repository to publish or resolve artifacts.
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:
- The NuGet gallery exposes its feed resource at https://www.nuget.org/api/v2/Packages and its download resource at https://www.nuget.org/api/v2/package
Therefore, to define this as a new repository you should set the repository URL to
https://www.nuget.org, its Feed Context Path to
api/v2and the Download Context Path to
NuGet.Servermodule exposes its feed resource at http://host:port/nuget/Packages and its download resource at http://host:port/api/v2/package.
To define this as a new repository you should set the repository URL to http://host:port, its Feed Context Path to
nugetand its Download Context Path to
- Another Artifactory repository exposes its feed resource at http://host:port/artifactory/api/nuget/repoKey/Packages and its download resource at http://host:port/artifactory/api/nuget/repoKey/Download.
To define this as a new repository you should set the repository URL to http://host:port/artifactory/api/nuget/repoKey, its Feed Context Path should be left empty and its Download Context Path to Download, like this:
Using a proxy server
If you are accessing NuGet Gallery through a proxy server you need to define the following two URLs in the proxy's white list:
- az320820.vo.msecnd.net (our current CDN domain)
For more details please refer to Allowing Access to NuGet.org Through Firewalls.
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 create a virtual Bower repository set NuGet to be its Package Type, and select the underlying local and remote NuGet repositories to include under the Repositories section.
Accessing NuGet Repositories from Visual Studio
NuGet repositories must be prefixed with api/nuget in the path
When configuring Visual Studio to access a NuGet repository through Artfactory, the repository URL must be prefixed with api/nuget in the path.
For example, if you are using Artifactory standalone or as a local service, you would configure Visual Studio using the following URL:
Or, if you are using Artifactory SaaS the URL would be:
https://<server name>.jfrog.io/<server name>/api/nuget/<repository key>
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: (You can access Options from the Tools menu).
Using the NuGet Command Line
NuGet repositories must be prefixed with api/nuget in the path
When using the NuGet command line to access a repository through Artfactory, the repository URL must be prefixed with api/nuget in the path. This applies to all NuGet commands including
nuget install and
For example, if you are using Artifactory standalone or as a local service, you would access your NuGet repositories using the following URL:
Or, if you are using Artifactory Online the URL would be:
https://<server name>.artifactoryonline.com/<server name>/api/nuget/<repository key>
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
apikey. 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:
Anonymous Access to NuGet Repositories
By default, Artifactory allows anonymous access to NuGet repositories. This is defined under Security | General Configuration. For details please refer to Allow Anonymous Access.
Working Without Anonymous Access
In order to be able to trace how users interact with your repositories we recommend that you uncheck the Allow Anonymous Access setting described above. This means that users will be required to enter their user name and password when using their NuGet clients.
You can configure your NuGet client to require a username and password using the following command:
You can verify that your setting has taken effect by checking that the following segment appears in your
NuGet.Config file can also be placed in your project directory, for further information please refer to
NuGet Configuration File
Allowing Anonymous Access
Artifactory supports NuGet repositories with Allow Anonymous Access enabled.
When Allow Anonymous Access is enabled, Artifactory will not query the NuGet client for authentication parameters by default, so you need to indicate to Artifactory to request authentication parameters in a different way.
You can override the default behavior by setting the Force Authentication checkbox in the New or Edit Repository dialog.
When set, Artifactory will first request authentication parameters from the NuGet client before trying to access this repository.
Viewing Individual NuGet Package Information
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: