Skip to main content

nuget-quickstart

Last updated on

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

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

Configure the upstream proxy in your registry

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:

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>
nuget setapikey <TOKEN> -Source harness
info

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:

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

Publish Package

Publish your package:

nuget push <PACKAGE_FILE> -Source harness
info

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

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