> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/artifact-registry/new-to-artifact-registry/quickstart/nuget-quickstart.md).

# Nuget

{% @harness-package-selector/package-selector platforms="%5B%7B%22label%22%3A%22Docker%22%2C%22slug%22%3A%22docker%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fdocker-quickstart%22%7D%2C%7B%22label%22%3A%22Helm%22%2C%22slug%22%3A%22helm%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fhelm-quickstart%22%7D%2C%7B%22label%22%3A%22Helm%20HTTP%22%2C%22slug%22%3A%22helm-http%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fhelm-http-quickstart%22%7D%2C%7B%22label%22%3A%22Generic%22%2C%22slug%22%3A%22generic%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fgeneric-quickstart%22%7D%2C%7B%22label%22%3A%22Raw%20File%22%2C%22slug%22%3A%22raw-file%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fraw-file-quickstart%22%7D%2C%7B%22label%22%3A%22Maven%22%2C%22slug%22%3A%22maven%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fmaven-quickstart%22%7D%2C%7B%22label%22%3A%22Python%22%2C%22slug%22%3A%22python%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fpython-quickstart%22%7D%2C%7B%22label%22%3A%22NPM%22%2C%22slug%22%3A%22npm%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fnpm-quickstart%22%7D%2C%7B%22label%22%3A%22Nuget%22%2C%22slug%22%3A%22nuget%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fnuget-quickstart%22%7D%2C%7B%22label%22%3A%22RPM%22%2C%22slug%22%3A%22rpm%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Frpm-quickstart%22%7D%2C%7B%22label%22%3A%22Debian%22%2C%22slug%22%3A%22debian%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fdebian-quickstart%22%7D%2C%7B%22label%22%3A%22Alpine%22%2C%22slug%22%3A%22alpine%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Falpine-quickstart%22%7D%2C%7B%22label%22%3A%22Wolfi%22%2C%22slug%22%3A%22wolfi%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fwolfi-quickstart%22%7D%2C%7B%22label%22%3A%22Cargo%22%2C%22slug%22%3A%22cargo%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fcargo-quickstart%22%7D%2C%7B%22label%22%3A%22Conan%22%2C%22slug%22%3A%22conan%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fconan-quickstart%22%7D%2C%7B%22label%22%3A%22Go%22%2C%22slug%22%3A%22go%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fgo-quickstart%22%7D%2C%7B%22label%22%3A%22Hugging%20Face%22%2C%22slug%22%3A%22hugging-face%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fhugging-face-quickstart%22%7D%2C%7B%22label%22%3A%22Conda%22%2C%22slug%22%3A%22conda%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fconda-quickstart%22%7D%2C%7B%22label%22%3A%22Dart%22%2C%22slug%22%3A%22dart%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fdart-quickstart%22%7D%2C%7B%22label%22%3A%22PHP%20Composer%22%2C%22slug%22%3A%22php-composer%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fphp-composer-quickstart%22%7D%2C%7B%22label%22%3A%22Swift%22%2C%22slug%22%3A%22swift%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fswift-quickstart%22%7D%2C%7B%22label%22%3A%22Puppet%22%2C%22slug%22%3A%22puppet%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fpuppet-quickstart%22%7D%2C%7B%22label%22%3A%22Terraform%22%2C%22slug%22%3A%22terraform%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fterraform-quickstart%22%7D%2C%7B%22label%22%3A%22R%20(CRAN)%22%2C%22slug%22%3A%22r-cran%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fr-cran-quickstart%22%7D%2C%7B%22label%22%3A%22RubyGems%22%2C%22slug%22%3A%22rubygems%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Frubygems-quickstart%22%7D%5D" selectedPlatform="nuget" %}

### Prerequisites <a href="#prerequisites" id="prerequisites"></a>

* 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 <a href="#create-a-nuget-artifact-registry" id="create-a-nuget-artifact-registry"></a>

{% tabs %}
{% tab title="Interactive Guide" %}
{% embed url="<https://app.tango.us/app/embed/1bb9ebd1-54c8-4585-87dd-e5e0b828acfb?skipCover=false&defaultListView=false&skipBranding=false&makeViewOnly=true&hideAuthorAndDetails=true>" %}
Create a NuGet Artifact Registry in Harness
{% endembed %}
{% endtab %}

{% tab title="Step-by-Step" %}

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**.

{% hint style="info" %}
**REGISTRY NAME CRITERIA**

Your registry name must start with a letter and can include `lowercase alphanumerics`, `_`, `.` and `-`.
{% endhint %}

5. Optionally, add a Description and Labels for better organization.
6. Choose visibility between **Public** and **Private**.
7. Click **Create Registry** to finalize.
   {% endtab %}
   {% endtabs %}

{% hint style="info" %}
**PRIVATE REGISTRY**

This registry will serve as your private NuGet registry within Harness.
{% endhint %}

***

### Configure an Upstream Proxy (Optional) <a href="#configure-an-upstream-proxy-optional" id="configure-an-upstream-proxy-optional"></a>

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

{% tabs %}
{% tab title="Interactive Guides" %}

#### Create an upstream proxy

{% embed url="<https://app.tango.us/app/embed/eb26ec8b-6b08-4434-8003-1e9c009f6212?skipCover=false&defaultListView=false&skipBranding=false&makeViewOnly=true&hideAuthorAndDetails=true>" %}
Create a NuGet Upstream Proxy in Harness
{% endembed %}

#### Configure the upstream proxy in your registry

{% embed url="<https://app.tango.us/app/embed/bc5364f0-51bc-4b7c-8dd6-8a1bc8d8c03c?skipCover=false&defaultListView=false&skipBranding=false&makeViewOnly=true&hideAuthorAndDetails=true>" %}
Configure NuGet Upstream Proxy in Harness
{% endembed %}
{% endtab %}

{% tab title="Step-by-Step" %}

#### 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.
{% endtab %}
{% endtabs %}

{% hint style="info" %}
**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.
{% endhint %}

***

### Install and Use NuGet Packages <a href="#install-and-use-nuget-packages" id="install-and-use-nuget-packages"></a>

{% tabs %}
{% tab title="Nuget" %}
**Configure Authentication**

**Step 1**

Add the Harness Registry as a package source:

```bash
nuget sources add -Name harness -Source https://pkg.harness.io/pkg/<account-id>/<nuget-registry-name>/nuget/index.json -Username john.doe@harness.io -Password <TOKEN>
```

```bash
nuget setapikey <TOKEN> -Source harness
```

{% hint style="info" %}
Note: For Nuget V2 Client, use this url: `https://pkg.harness.io/pkg/<account-id>/<nuget-registry-name>/nuget/`
{% endhint %}

**Step 2**

Generate an identity token for authentication

**Install Package**

Install a package using nuget:

```bash
nuget install <ARTIFACT_NAME> -Version <VERSION> -Source harness
```

**Publish Package**

Publish your package:

```bash
nuget push <PACKAGE_FILE> -Source harness
```

{% hint style="info" %}
Note: To publish your package with nested directory, refer below command

```bash
nuget push <PACKAGE_FILE> -Source https://pkg.harness.io/pkg/<account-id>/<nuget-registry-name>/nuget/<SUB_DIRECTORY> -ApiKey <TOKEN>
```

{% endhint %}
{% endtab %}

{% tab title="Dotnet" %}
**Configure Authentication**

**Step 1**

Add the Harness Registry as a package source:

```bash
dotnet nuget add source https://pkg.harness.io/pkg/<account-id>/<nuget-registry-name>/nuget/index.json --name harness --username john.doe@harness.io --password <TOKEN> --store-password-in-clear-text
```

{% hint style="info" %}
Note: For Nuget V2 Client, use this url: `https://pkg.harness.io/pkg/<account-id>/<nuget-registry-name>/nuget/`
{% endhint %}

**Step 2**

Generate an identity token for authentication

**Install Package**

Add a package using dotnet:

```bash
dotnet package add <ARTIFACT_NAME> --version <VERSION> --source harness
```

**Publish Package**

Publish your package:

```bash
dotnet nuget push <PACKAGE_FILE> --api-key <TOKEN> --source harness
```

{% hint style="info" %}
Note: To publish your package with nested directory, refer below command

```bash
dotnet nuget push <PACKAGE_FILE> --source https://pkg.harness.io/pkg/<account-id>/<nuget-registry-name>/nuget/<SUB_DIRECTORY> --api-key <TOKEN>
```

{% endhint %}
{% endtab %}

{% tab title="Visual Studio" %}
**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:

```xml
<?xml version="1.0" encoding="utf-8"?>
<configuration>
 <packageSources>
     <clear />
     <add key="harness" value="https://pkg.harness.io/pkg/<account-id>/<nuget-registry-name>/nuget/index.json" />
 </packageSources>
 <packageSourceCredentials>
     <harness>
         <add key="Username" value="john.doe@harness.io" />
         <add key="ClearTextPassword" value="<TOKEN>" />
     </harness>
 </packageSourceCredentials>
</configuration>
```

![NuGet Config Example](/files/XXqsIzb65ib9jzVhuLOh)

{% hint style="info" %}
You can get this configuration from your Harness client setup details.
{% endhint %}

**Step 5**

Generate an identity token for authentication in the Harness platform and replace `<TOKEN>` in the configuration with your actual token.
{% endtab %}
{% endtabs %}
