For the complete documentation index, see llms.txt. This page is also available as Markdown.

Nuget

spinner

Prerequisites

  • Ensure you have the NuGet CLI (nuget) installed on your local machine.

  • Access to a Harness account with appropriate permissions to create registries and connectors.


Create a NuGet artifact registry

Create a NuGet Artifact Registry in Harness
  1. Navigate to the Artifact Registry module in your Harness project.

  2. Click on New Artifact Registry.

  3. In the Registry Type dropdown, select NuGet Registry.

  4. Provide a Registry Name.

REGISTRY NAME CRITERIA

Your registry name must start with a letter and can include lowercase alphanumerics, _, . and -.

  1. Optionally, add a Description and Labels for better organization.

  2. Choose visibility between Public and Private.

  3. Click Create Registry to finalize.

PRIVATE REGISTRY

This registry will serve as your private NuGet registry within Harness.


Configure an Upstream Proxy (Optional)

An upstream proxy allows your registry to fetch NuGet packages from external sources if they are not available locally.

Create an upstream proxy

Create a NuGet Upstream Proxy in Harness

Configure the upstream proxy in your registry

Configure NuGet Upstream Proxy in Harness

Create an upstream proxy

1. In the Artifact Registry module, click the dropdown next to **New Artifact Registry** and select **Upstream Proxy**. 2. Choose **Nuget Registry** as the proxy type. 3. Click **Create Proxy** to establish the connection.

Configure the upstream proxy in your registry

1. In the Artifact Registry module, select an existing Artifact Registry. 2. Select the **Configuration** tab. 3. Under **Advanced (Optional)**, select **Configure Upstream**. 4. Select from the list of compatible proxies to add them to your registry. 5. Click **Save** to save the configuration.

UPSTREAM PROXY CACHING

If a NuGet package isn’t found in your Harness registry, the upstream proxy can fetch it from an external source like NuGet.org, helping to reduce duplication and ensure reliable access to public packages.


Install and Use NuGet Packages

Configure Authentication

Step 1

Add the Harness Registry as a package source:

Note: For Nuget V2 Client, use this url: https://pkg.harness.io/pkg/<account-id>/<nuget-registry-name>/nuget/

Step 2

Generate an identity token for authentication

Install Package

Install a package using nuget:

Publish Package

Publish your package:

Note: To publish your package with nested directory, refer below command

Configure Authentication

Step 1

Add the Harness Registry as a package source:

Note: For Nuget V2 Client, use this url: https://pkg.harness.io/pkg/<account-id>/<nuget-registry-name>/nuget/

Step 2

Generate an identity token for authentication

Install Package

Add a package using dotnet:

Publish Package

Publish your package:

Note: To publish your package with nested directory, refer below command

Configure Nuget Package Source in Visual Studio

Step 1

Open your project in Visual Studio, then navigate to the NuGet Package Manager settings:

  1. Click on Tools in the top menu

  2. Select NuGet Package Manager

  3. Click on Package Manager Settings

Step 2

In the Options window that appears, click on Package Sources in the left panel.

You will see the location of your NuGet.Config file displayed at the top of this window. Take note of this location as you can also directly edit this file if needed.

Step 3

In the Package Sources window:

  1. Click the + button to add a new package source

  2. Set the Name to harness

  3. Set the Source to https://pkg.harness.io/pkg/<account-id>/<nuget-registry-name>/nuget/index.json

  4. Click Update and then OK

Step 4

Locate and open your NuGet.Config file (shown at the top of the Package Sources window) and ensure it contains the following configuration:

NuGet Config Example

You can get this configuration from your Harness client setup details.

Step 5

Generate an identity token for authentication in the Harness platform and replace <TOKEN> in the configuration with your actual token.

Last updated

Was this helpful?