Use .NET CLI with JFrog CLI
Configure jf dotnet to resolve NuGet packages through JFrog Artifactory with build-info.
Run .NET CLI commands with Artifactory integration for dependency resolution and build information collection.
This topic covers the following tasks:
When to Use
Use jf dotnet if your .NET project uses the .NET SDK CLI (dotnet restore, dotnet build) for builds. For projects using the NuGet CLI directly, use jf nuget instead.
Package Alias (Ghost Frog)
To run native
dotnetcommands without thejfprefix, see Use JFrog CLI Package Alias.
Prerequisites
- A .NET project must exist in the current directory (a
.csprojor.slnfile). If you don't have one yet, create one withdotnet new. - JFrog CLI server configured. See
jf config add— note the server ID you use, as it is required byjf dotnet-config. - Authentication: A valid Artifactory access token is required. If your token is a reference token (non-JWT), you must also supply a username when configuring the server — NuGet uses basic authentication and requires both a username and password/token. Re-run
jf config addand provide a username if you seeValue cannot be null or empty string. (Parameter 'username')errors. - Run
jf dotnet-configin the project directory before the first build.
Configuration: jf dotnet-config
Generate .NET configuration for resolving packages through Artifactory. Run this once per project before your first build.
To configure .NET for Artifactory:
- From your project directory (containing a
.csprojor.sln), runjf dotnet-configwith--server-id-resolveand--repo-resolve(see Non-Interactive Configuration). - Confirm
.jfrog/projects/dotnet.yamlwas created (see How to Verify).
Synopsis
jf dotnet-config [options]
Aliases: dotnetc
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 dotnet-config --helpNon-Interactive Configuration
Configure .NET with non-interactive flags:
jf dotnet-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
For example:
jf dotnet-config --server-id-resolve=my-server --repo-resolve=nuget-virtualWhy Run Config First?
You must run jf dotnet-config before jf dotnet restore. The config creates .jfrog/projects/dotnet.yaml for NuGet package resolution through Artifactory. Without it, jf dotnet does not know where to fetch packages.
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: Use
--nuget-v2=trueonly if your Artifactory NuGet repository is configured for the V2 protocol. Most modern setups use V3. - Alternative: For NuGet-only projects (not using .NET SDK), use
jf nugetinstead.
Expected Output
$ jf dotnet-config --server-id-resolve=my-server --repo-resolve=nuget-virtual
[Info] dotnet build config successfully created.
How to Verify
After running, confirm the configuration exists:
cat .jfrog/projects/dotnet.yamlThe file should contain:
version: 1
type: dotnet
resolver:
repo: <repo-name>
serverId: <server-id>Where <repo-name> and <server-id> match the values you passed to jf dotnet-config.
Build: jf dotnet
Run .NET CLI commands with Artifactory integration for dependency resolution and build information collection.
To run .NET CLI with Artifactory integration:
- Run
jf dotnet-configin the project directory if you have not already (see Configuration). - From the project root, run
jf dotnetwith the .NET subcommand (for example,restore,build), adding--build-nameand--build-numberwhen you want build-info (see Build Examples).
Synopsis
jf dotnet <dotnet-arguments> [options]
Aliases: none
Arguments
| Argument | Required | Description |
|---|---|---|
dotnet-arguments | Yes | .NET subcommand and arguments (for example, restore, build, publish) |
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). This flag is functional but does not appear in jf dotnet --help output. |
Build Examples
Note
Run these commands from the root of your .NET project directory (where your
.csprojor.slnfile lives), and only after runningjf dotnet-configin that directory.
Restore and Build
jf dotnet restore
jf dotnet buildOn success, restore ends with:
Restore succeeded.
And build ends with:
Build succeeded.
Build with Build Information
jf dotnet restore --build-name=<build-name> --build-number=<build-number>
jf dotnet build --build-name=<build-name> --build-number=<build-number>Where:
<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 dotnet restore --build-name=my-dotnet-app --build-number=1
jf dotnet build --build-name=my-dotnet-app --build-number=1Publish Build Info
After restoring and building with --build-name and --build-number, publish the collected build info to Artifactory:
jf rt build-publish <build-name> <build-number>For example:
jf rt build-publish my-dotnet-app 1Tip
jf rt bpis a shorthand alias forjf rt build-publish.
Important Notes
- dotnet vs nuget:
jf dotnetwraps the .NET CLI (which includes NuGet functionality). Usejf dotnetfor .NET SDK-style projects andjf nugetfor traditional NuGet-only projects. - Supported subcommands:
jf dotnetaccepts any .NET subcommand and forwards it to the nativedotnetCLI. To route package resolution through Artifactory, JFrog CLI injects a temporary--configfileinto each call (unless you pass--configfileor--sourceyourself). This is designed for restore-oriented workflows;restoreandbuildare the primary supported subcommands. A subcommand succeeds only if nativedotnetaccepts--configfilefor that command. Subcommands such asadd packagedo not, and fail with anUnrecognized command or argument '--configfile'error when run throughjf dotnet. Use nativedotnetfor those commands. - dotnet test: JFrog CLI does not inject
--configfilefortest; it adds--no-restoreinstead. Runjf dotnet restorewith build-info flags beforejf dotnet test. - Build-info: Use
--build-nameand--build-number, then publish withjf rt build-publish.
CI/CD Example: GitHub Actions
Package Alias (Ghost Frog)
To run
dotnetwithout thejfprefix, enable Package Alias insetup-jfrog-cliand setJFROG_CLI_GHOST_FROG=true. If you install the tool after the action (for examplesetup-javaorsetup-node), re-pin the alias path toGITHUB_PATH. See Use JFrog CLI Package Alias.
# .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: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Configure .NET
run: jf dotnet-config --server-id-resolve=setup-jfrog-cli-server --repo-resolve=nuget-virtual
- name: Restore packages
run: jf dotnet restore --build-name=my-dotnet-app --build-number=${{ github.run_number }}
- name: Build
run: jf dotnet build
- name: Publish build info
run: jf rt build-publish my-dotnet-app ${{ github.run_number }}Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
Value cannot be null or empty string. (Parameter 'username') | Access token is a reference token (non-JWT); NuGet requires basic auth with a username | Re-run jf config add and provide a username when prompted, or use a JWT access token. The CLI will warn: The provided access token is not a valid JWT, probably a reference token. |
No .csproj or .sln found | jf dotnet restore/build run outside a .NET project directory | Run the command from the directory containing your .csproj or .sln, or create a project first with dotnet new |
no config file was found | jf dotnet-config was not run | Run jf dotnet-config in the project directory |
404 on jf dotnet 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 dotnet-config |
Build-info not collected for dotnet test | The test command uses --no-restore implicitly | Run jf dotnet restore separately with build-info flags before jf dotnet test |
Unknown option or unrecognized --configfile on jf dotnet | The subcommand does not accept --configfile; JFrog CLI injects it on every call except test | Use native dotnet for that subcommand (for example, add package), or pass your own --configfile / --source to skip auto-injection where supported |
Enable debug logging: export JFROG_CLI_LOG_LEVEL=DEBUG
Frequently Asked Questions
This section provides answers to frequently asked questions about using the .NET CLI with JFrog CLI.
FAQs
Q: How do I run .NET builds with jf dotnet and build-info?
A: Run jf dotnet restore and jf dotnet build with --build-name and --build-number, then publish with jf rt build-publish. See Build: jf dotnet.
Q: What do I need before using jf dotnet with Artifactory?
A: You need a .NET project with a .csproj or .sln file, a configured JFrog CLI server, and jf dotnet-config run once in the project directory. See Prerequisites.
Q: What is the difference between jf dotnet and jf nuget?
A: jf dotnet wraps the .NET SDK CLI for projects that use dotnet restore and dotnet build. jf nuget is for traditional NuGet-only projects that don't use the .NET SDK. See Important Notes.
Q: Why do I see a username parameter error when running jf dotnet-config?
A: Your Artifactory access token is a reference token (non-JWT), and NuGet requires basic authentication with a username. Re-run jf config add and provide a username. See Troubleshooting.
Q: Can I run jf dotnet add package through Artifactory?
A: No. JFrog CLI injects --configfile only for subcommands that accept it, such as restore and build. Subcommands like add package fail with an unrecognized argument error. Use native dotnet for those commands. See Important Notes.
Related Topics
Updated 2 days ago
