---
updatedAt: 2026-10-05T04:59:16.000Z
agentTools:
  siteIndex: https://docs.jfrog.com/llms.txt
  projectIndex: https://docs.jfrog.com/artifactory/llms.txt
---

# Use NuGet with JFrog CLI

Configure and run jf nuget with JFrog Artifactory for NuGet resolution, publishing, and build-info.

Run NuGet commands with Artifactory integration for dependency resolution and build information collection.

This topic covers the following tasks:

* [Configure NuGet for Artifactory (`jf nuget-config`)](#configuration-jf-nuget-config)
* [Run NuGet commands (`jf nuget`)](#build-jf-nuget)
* [Native Mode](#native-mode)

## When to Use

Choose the right command based on which tool you have installed:

* **Have `nuget` CLI installed?** → Use `jf nuget` (this page).
* **Have `dotnet` SDK installed?** → Use [`jf dotnet`](/docs/jf-dotnet) instead.

`jf nuget` requires the NuGet CLI binary (`nuget`) to be in your `$PATH`. It does not work with the .NET SDK CLI (`dotnet`). For projects using `dotnet restore` or `dotnet build`, use [`jf dotnet`](/docs/jf-dotnet).

<Callout icon="📘" theme="info">
  **Package Alias (Ghost Frog)**

  To run native `nuget` commands without the `jf` prefix, see [Use JFrog CLI Package Alias](/artifactory/docs/jfrog-cli-package-alias).
</Callout>

<Callout icon="📘" theme="info">
  **Package manager version compatibility**

  Before you begin, review [Supported Package Manager Versions](/artifactory/docs/package-manager-compatibility-matrix) for the NuGet and .NET SDK versions supported and tested with JFrog CLI.
</Callout>

## Prerequisites

* **NuGet CLI installed** and available in `$PATH`. Verify with:

  ```bash
  nuget help
  ```

  If not installed:

  * **macOS**: `brew install nuget`
  * **Linux**: Download from [nuget.org/downloads](https://www.nuget.org/downloads) and add to `$PATH`.
  * **Windows**: Included with Visual Studio, or download from [nuget.org/downloads](https://www.nuget.org/downloads).

* **JFrog CLI server configured** with `jf config add` or `jf c add`. Use a scoped access token (JWT). Reference tokens require a username — see [Troubleshooting](#troubleshooting).

* **Choose a mode**: For the default Wrapped Mode, run `jf nuget-config` in the project directory before the first build. For Native Mode, use JFrog CLI 2.123.0 or later, set `JFROG_RUN_NATIVE=true`, and pass the repository on the command. For more information, see [Native Mode](#native-mode).

* **Artifactory NuGet repository** exists and your account has read (and write, for push) permissions.

***

## Configuration: jf nuget-config

Generate NuGet configuration for resolving packages through Artifactory. **Run this once per project before your first build.**

**To configure NuGet for Artifactory:**

1. From your project directory, run `jf nuget-config` with `--server-id-resolve` and `--repo-resolve` (see [Non-Interactive Configuration](#non-interactive-configuration)).
2. Confirm `.jfrog/projects/nuget.yaml` exists (see [How to Verify](#how-to-verify)).

### Synopsis

```
jf nuget-config [options]
```

**Aliases:** `nugetc`

### Configuration Options

| Flag                  | Default | Description                                           |
| --------------------- | ------- | ----------------------------------------------------- |
| `--global`            | `false` | Apply configuration globally for all projects         |
| `--server-id-resolve` | —       | Artifactory server ID for dependency resolution       |
| `--repo-resolve`      | —       | Repository for resolving packages                     |
| `--nuget-v2`          | `false` | Use NuGet V2 protocol when restoring from Artifactory |

### Configuration Examples

#### View Help

```bash
jf nuget-config --help
```

#### Non-Interactive Configuration

Configure NuGet with non-interactive flags:

```bash
jf nuget-config --server-id-resolve=<server-id> --repo-resolve=<repo-name>
```

Where:

* `<server-id>`: The server ID configured using `jf config add`
* `<repo-name>`: The name of the NuGet repository in Artifactory

<Callout icon="📘" theme="info">
  **Note**

  Both `--server-id-resolve` and `--repo-resolve` are required for non-interactive use. Omitting either flag launches an interactive configuration wizard, which is not suitable for CI/CD pipelines.
</Callout>

For example:

```bash
jf nuget-config --server-id-resolve=my-server --repo-resolve=nuget-virtual
```

### Why Run Config First?

In Wrapped Mode, run `jf nuget-config` before `jf nuget restore`. The command creates `.jfrog/projects/nuget.yaml` so NuGet can resolve packages through Artifactory. Without that file, Wrapped Mode can't tell which repository to use. Native Mode doesn't use this file. For more information, see [Native Mode](#native-mode).

If you skip this step, you will see the error: `no config file was found! Before running the 'jf nuget' command on a project for the first time, the project should be configured with the 'jf nuget-config' command`.

<Callout icon="👍" theme="okay">
  **Shortcut**

  In CI/CD, pass all flags non-interactively so the config step is fully automated and reproducible.
</Callout>

### Configuration Notes

* **Run once per project**: Re-run when changing the resolution repository.
* **NuGet V2**: Set `--nuget-v2=true` only if your Artifactory NuGet repository uses V2 protocol.
* **Alternative**: For .NET SDK projects, use [`jf dotnet`](/docs/jf-dotnet) for broader .NET integration.

### Expected Output

```
$ jf nuget-config --server-id-resolve=my-server --repo-resolve=nuget-virtual
[Info] nuget build config successfully created.
```

### How to Verify

After running, confirm the configuration exists:

```bash
cat .jfrog/projects/nuget.yaml
```

Expected contents:

```yaml
version: 1
type: nuget
resolver:
    repo: <repo-name>
    serverId: <server-id>
```

***

## Build: jf nuget

Run NuGet commands with Artifactory integration for dependency resolution and build information collection.

**To run NuGet with Artifactory integration:**

1. Run `jf nuget-config` in the project directory if you have not already (see [Configuration](#configuration-jf-nuget-config)).
2. Run `jf nuget` with the NuGet command and arguments, adding `--build-name` and `--build-number` when you want build-info (see [Build Examples](#build-examples)).

### Synopsis

```
jf nuget <nuget-arguments> [options]
```

**Aliases:** none

### Arguments

| Argument          | Required | Description                                                  |
| ----------------- | -------- | ------------------------------------------------------------ |
| `nuget-arguments` | Yes      | NuGet command and arguments (for example, `restore`, `push`) |

### Build Options

| Flag                           | Default | Description                                                       |
| ------------------------------ | ------- | ----------------------------------------------------------------- |
| `--build-name`                 | —       | Build name for build information (requires `--build-number`)      |
| `--build-number`               | —       | Build number for build information (requires `--build-name`)      |
| `--project`                    | —       | JFrog Artifactory project key                                     |
| `--module`                     | —       | Optional module name for build information                        |
| `--allow-insecure-connections` | `false` | Configure NuGet sources with unsecured connections (testing only) |

### Build Examples

#### Restore Packages

```bash
jf nuget restore
```

Expected output (success):

```
[Info] Running nuget...
[Info] Resolving packages from Artifactory...
MSBuild auto-detection: using msbuild version '...' from '...'
Restoring packages for <project>.csproj...
...
[Info] Building build-info...
[Info] Build-info successfully created.
```

#### Push with Build Information

```bash
jf nuget push <package-path> --build-name=<build-name> --build-number=<build-number>
```

Where:

* `<package-path>` is the path to the `.nupkg` file (for example, `bin/Release/MyPackage.1.0.0.nupkg`)
* `<build-name>` is a name for the build (for example, `my-dotnet-app`)
* `<build-number>` is a number or identifier for the build run (for example, `1`)

For example:

```bash
jf nuget push bin/Release/MyPackage.1.0.0.nupkg --build-name=my-dotnet-app --build-number=1
```

Expected output (success):

```
[Info] Running nuget...
[Info] Pushing bin/Release/MyPackage.1.0.0.nupkg to nuget-virtual...
[Info] Build-info successfully created.
```

After collecting build info, publish it with:

```bash
jf rt build-publish my-dotnet-app 1
```

***

## Important Notes

* **Supported commands**: `jf nuget` accepts any NuGet subcommand and forwards it to the native `nuget` CLI. To route package resolution through Artifactory, JFrog CLI injects a temporary `-configfile` into each call (unless you pass `-configfile` or `-source` yourself). `restore` is the primary supported command. Other NuGet commands succeed only if native `nuget` accepts `-configfile` for that command. Otherwise, use native `nuget`.
* **NuGet v2 vs v3**: Use `--nuget-v2` in `jf nuget-config` if your Artifactory NuGet repository is configured for the V2 protocol.
* **Insecure connections**: The `--allow-insecure-connections` flag is for **testing only**. Do not use in production.
* **Build-info**: Use `--build-name` and `--build-number`, then publish with `jf rt build-publish`.
* **Alternative**: For .NET projects, `jf dotnet` provides similar functionality using the .NET CLI instead of NuGet directly.

## Native Mode

Set `JFROG_RUN_NATIVE=true` to run NuGet with your own configuration and still collect build-info through `jf nuget`. Native Mode is available in JFrog CLI 2.123.0 or later. You can skip `jf nuget-config`. If `.jfrog/projects/nuget.yaml` is already in the project, delete it first. Otherwise JFrog CLI keeps using Wrapped Mode.

```bash
export JFROG_RUN_NATIVE=true
jf nuget restore MyApp.sln --repo-resolve=nuget-virtual --build-name=my-app --build-number=1 --server-id=my-server
jf nuget push MyLib.1.0.0.nupkg --repo=nuget-local --build-name=my-app --build-number=1 --server-id=my-server
jf rt bp my-app 1
```

The `restore`, `install`, and `update` commands record dependencies. The `push` and `pack` commands record package artifacts. `nuget` can't restore `.slnx` solutions. Use [`jf dotnet`](/docs/jf-dotnet) for those projects.

For more information, see [NuGet Native Mode](/artifactory/docs/native-mode#nuget-native-mode).

## Running Builds with MSBuild

JFrog CLI includes integration with MSBuild and Artifactory, allowing you to resolve dependencies and deploy build artifacts while collecting build-info. This is done by having JFrog CLI in your search path and adding JFrog CLI commands to the MSBuild `.csproj` file. For detailed instructions, refer to the [MSBuild project example on GitHub](https://github.com/jfrog/project-examples).

## CI/CD Example: GitHub Actions

<Callout icon="📘" theme="info">
  **Package Alias (Ghost Frog)**

  To run `nuget` without the `jf` prefix, enable Package Alias in `setup-jfrog-cli` and set `JFROG_CLI_GHOST_FROG=true`. If you install the tool **after** the action (for example `setup-java` or `setup-node`), re-pin the alias path to `GITHUB_PATH`. See [Use JFrog CLI Package Alias](/artifactory/docs/jfrog-cli-package-alias#path-priority-and-re-pinning-aliases).
</Callout>

```yaml
# .github/workflows/build.yml
steps:
  - uses: actions/checkout@v4
  - name: Setup JFrog CLI
    uses: jfrog/setup-jfrog-cli@v4
    env:
      JF_URL: ${{ vars.JF_URL }}
      JF_ACCESS_TOKEN: ${{ secrets.JF_ACCESS_TOKEN }}
  - name: Configure NuGet
    run: jf nuget-config --server-id-resolve=setup-jfrog-cli-server --repo-resolve=nuget-virtual
  - name: Restore packages
    run: jf nuget restore --build-name=my-dotnet-app --build-number=${{ github.run_number }}
  - name: Publish build info
    run: jf rt build-publish my-dotnet-app ${{ github.run_number }}
```

## Troubleshooting

| Symptom                                                                       | Cause                                                                            | Fix                                                                                                                          |
| ----------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| `exec: "nuget": executable file not found in $PATH`                           | NuGet CLI is not installed or not in `$PATH`                                     | Install the NuGet CLI: `brew install nuget` (macOS), or download from [nuget.org/downloads](https://www.nuget.org/downloads) |
| `[Warn] couldn't extract payload from Access Token` / reference token warning | Access token is a reference token, not a JWT. NuGet requires basic auth          | Use a scoped access token (JWT), or re-configure with `jf config add` providing both a username and password/token           |
| `no config file was found`                                                    | `jf nuget-config` was not run                                                    | Run `jf nuget-config` in the project directory                                                                               |
| 404 on `jf nuget restore`                                                     | Resolution repository does not exist or name is wrong                            | Verify `--repo-resolve` matches an existing NuGet virtual repository in Artifactory                                          |
| 401 / 403 errors                                                              | Invalid credentials or insufficient permissions                                  | Re-run `jf config add` with a valid access token                                                                             |
| NuGet V2 protocol errors                                                      | Artifactory repo uses V2 but config defaults to V3                               | Set `--nuget-v2=true` in `jf nuget-config`                                                                                   |
| `jf nuget restore` fails with SSL errors                                      | Corporate proxy or self-signed certificates                                      | Use `--allow-insecure-connections` for testing (not recommended for production)                                              |
| Unknown option or unrecognized `-configfile` on `jf nuget`                    | The subcommand does not accept `-configfile`. JFrog CLI injects it on every call | Use native `nuget` for that subcommand, or pass your own `-configfile` / `-source` to skip auto-injection where supported    |

**Enable debug logging:** `export JFROG_CLI_LOG_LEVEL=DEBUG`

***

## Dependency tree: jf rt nuget-deps-tree

Display the NuGet dependency tree for the solution in the current directory. JFrog CLI 2.105.0+ supports `--format json` (default) or `--format table`.

```bash
jf rt nuget-deps-tree [--format json|table]
```

Run this command from the directory containing your restored `.sln` or `.csproj` file. It does not take a solution-path argument and does not contact Artifactory.

<Callout icon="👍" theme="okay">
  **Tip**

  `jf rt ndt` is a shorthand alias for `jf rt nuget-deps-tree`.
</Callout>

See [jf rt output format](/docs/jf-rt-output-format#jf-rt-nuget-deps-tree) for example output.

<br />

## Frequently Asked Questions

This section provides answers to frequently asked questions about using NuGet with JFrog CLI.

<Accordion title="FAQs" icon="plus">
  ##### Q: How do I run NuGet restore with build-info using jf nuget?

  **A:** In Wrapped Mode, run `jf nuget-config` once per project, then `jf nuget restore --build-name=<build-name> --build-number=<build-number>`, and publish with `jf rt build-publish`. In Native Mode, set `JFROG_RUN_NATIVE=true` and pass `--repo-resolve` instead of running `jf nuget-config`. For more information, see [Build: jf nuget](#build-jf-nuget) and [Native Mode](#native-mode).

  ##### Q: What is the difference between jf nuget and jf dotnet?

  **A:** Use `jf nuget` when the `nuget` CLI binary is installed and in your `$PATH`. Use `jf dotnet` for projects that use the `dotnet` SDK CLI instead. See [When to Use](#when-to-use).

  ##### Q: What do I need before running jf nuget-config?

  **A:** You need the NuGet CLI installed, a JFrog CLI server configured with `jf config add`, and an Artifactory NuGet repository with read (and write, for push) permissions. See [Prerequisites](#prerequisites).

  ##### Q: Why do I get a reference token warning when running jf nuget?

  **A:** NuGet requires basic authentication, and reference (identity) tokens do not carry a username. Re-configure the server with `jf config add`, providing both a username and a password or scoped access token. See [Troubleshooting](#troubleshooting).

  ##### Q: Can I view the NuGet dependency tree without contacting Artifactory?

  **A:** Yes. Run `jf rt nuget-deps-tree` (alias `jf rt ndt`) from the directory containing your restored `.sln` or `.csproj` file. See [Dependency tree: jf rt nuget-deps-tree](#dependency-tree-jf-rt-nuget-deps-tree).
</Accordion>

## Related Topics

* [Build Tools Overview](/artifactory/docs/build-tool-commands)
* [Native Mode](/artifactory/docs/native-mode)
* [Use JFrog CLI Package Alias](/artifactory/docs/jfrog-cli-package-alias)
* [Supported Package Manager Versions](/artifactory/docs/package-manager-compatibility-matrix)