Nuget
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
Navigate to the Artifact Registry module in your Harness project.
Click on New Artifact Registry.
In the Registry Type dropdown, select NuGet Registry.
Provide a Registry Name.
Optionally, add a Description and Labels for better organization.
Choose visibility between Public and Private.
Click Create Registry to finalize.
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
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.
Install and Use NuGet Packages
Configure Authentication
Step 1
Add the Harness Registry as a package source:
Step 2
Generate an identity token for authentication
Install Package
Install a package using nuget:
Publish Package
Publish your package:
Configure Authentication
Step 1
Add the Harness Registry as a package source:
Step 2
Generate an identity token for authentication
Install Package
Add a package using dotnet:
Publish Package
Publish your package:
Configure Nuget Package Source in Visual Studio
Step 1
Open your project in Visual Studio, then navigate to the NuGet Package Manager settings:
Click on Tools in the top menu
Select NuGet Package Manager
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:
Click the + button to add a new package source
Set the Name to
harnessSet the Source to
https://pkg.harness.io/pkg/<account-id>/<nuget-registry-name>/nuget/index.jsonClick 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:

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?