Use NuGet with JFrog CLI
Run NuGet commands with Artifactory integration for dependency resolution and build information collection.
This topic covers the following tasks:
When to Use
Choose the right command based on which tool you have installed:
- Have
nugetCLI installed? → Usejf nuget(this page). - Have
dotnetSDK installed? → Usejf dotnetinstead.
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.
Prerequisites
-
NuGet CLI installed and available in
$PATH. Verify with:nuget helpIf not installed:
- macOS:
brew install nuget - Linux: Download from nuget.org/downloads and add to
$PATH. - Windows: Included with Visual Studio, or download from nuget.org/downloads.
- macOS:
-
JFrog CLI server configured with
jf config addorjf c add. Use a scoped access token (JWT). Reference tokens require a username — see Troubleshooting. -
Run
jf nuget-configin the project directory before the first build. -
Artifactory NuGet repository exists and your account has read (and write, for push) permissions.
Configuration: jf nuget-config
jf nuget-configGenerate NuGet configuration for resolving packages through Artifactory. Run this once per project before your first build.
To configure NuGet for Artifactory:
- From your project directory, run
jf nuget-configwith--server-id-resolveand--repo-resolve(see Non-Interactive Configuration). - Confirm
.jfrog/projects/nuget.yamlexists (see 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
jf nuget-config --helpNon-Interactive Configuration
Configure NuGet with non-interactive flags:
jf nuget-config --server-id-resolve=<server-id> --repo-resolve=<repo-name>Where:
<server-id>: The server ID configured usingjf config add<repo-name>: The name of the NuGet repository in Artifactory
Note
: Both
--server-id-resolveand--repo-resolveare required for non-interactive use. Omitting either flag launches an interactive configuration wizard, which is not suitable for CI/CD pipelines.
For example:
jf nuget-config --server-id-resolve=my-server --repo-resolve=nuget-virtualWhy Run Config First?
You must run jf nuget-config before jf nuget restore. The config creates .jfrog/projects/nuget.yaml for NuGet package resolution through Artifactory. Without it, jf nuget does not know where to fetch packages.
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.
Shortcut
: In CI/CD, pass all flags non-interactively so the config step is fully automated and reproducible.
Configuration Notes
- Run once per project: Re-run when changing the resolution repository.
- NuGet V2: Set
--nuget-v2=trueonly if your Artifactory NuGet repository uses V2 protocol. - Alternative: For .NET SDK projects, use
jf dotnetfor 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:
cat .jfrog/projects/nuget.yamlExpected contents:
version: 1
type: nuget
resolver:
repo: <repo-name>
serverId: <server-id>Build: jf nuget
jf nugetRun NuGet commands with Artifactory integration for dependency resolution and build information collection.
To run NuGet with Artifactory integration:
- Run
jf nuget-configin the project directory if you have not already (see Configuration). - Run
jf nugetwith the NuGet command and arguments, adding--build-nameand--build-numberwhen you want build-info (see 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
jf nuget restoreExpected 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
jf nuget push <package-path> --build-name=<build-name> --build-number=<build-number>Where:
<package-path>is the path to the.nupkgfile (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:
jf nuget push bin/Release/MyPackage.1.0.0.nupkg --build-name=my-dotnet-app --build-number=1Expected 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:
jf rt build-publish my-dotnet-app 1Important Notes
- NuGet v2 vs v3: Use
--nuget-v2injf nuget-configif your Artifactory NuGet repository is configured for the V2 protocol. - Insecure connections: The
--allow-insecure-connectionsflag is for testing only. Do not use in production. - Build-info: Use
--build-nameand--build-number, then publish withjf rt build-publish. - Alternative: For .NET projects,
jf dotnetprovides similar functionality using the .NET CLI instead of NuGet directly.
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.
CI/CD Example (GitHub Actions)
# .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 |
[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) |
Enable debug logging: export JFROG_CLI_LOG_LEVEL=DEBUG
Related Topics
- Build Tools Overview — Capabilities matrix and tool reference
- Native Mode — Supported packages with Native Mode
Updated about 1 month ago
