# jf dotnet Run .NET CLI commands with Artifactory integration for dependency resolution and build information collection. This topic covers the following tasks: * [Configure .NET for Artifactory (`jf dotnet-config`)](#configuration-jf-dotnet-config) * [Run .NET CLI commands (`jf dotnet`)](#build-jf-dotnet) ## 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`](jf-nuget.md) instead. ## Prerequisites * Run `jf dotnet-config` in the project directory before the first build. * Configure a server with `jf config add` or `jf c add`. * Authentication to Artifactory is required. *** ## 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:** ### 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 ```bash jf dotnet-config --help ``` #### Non-Interactive Configuration Configure .NET with non-interactive flags: ```bash jf dotnet-config --server-id-resolve= --repo-resolve= ``` Where: * \: The server ID configured using `jf config add` * \: The name of the NuGet repository in Artifactory For example: ```bash jf dotnet-config --server-id-resolve=my-server --repo-resolve=nuget-virtual ``` ### Why 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=true` only 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 nuget`](jf-nuget.md) instead. ### Expected Output ``` $ jf dotnet-config --server-id-resolve=my-server --repo-resolve=nuget-virtual .NET build configuration saved successfully. ``` ### How to Verify After running, confirm the configuration exists: ```bash cat .jfrog/projects/dotnet.yaml ``` *** ## Build: `jf dotnet` Run .NET CLI commands with Artifactory integration for dependency resolution and build information collection. **To run .NET CLI with Artifactory integration:** ### Synopsis ``` jf dotnet [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 #### Restore and Build ```bash jf dotnet restore jf dotnet build ``` #### Build with Build Information ```bash jf dotnet build --build-name= --build-number= ``` Where: * `` is a name for the build (e.g., `my-dotnet-app`) * `` is a number or identifier for the build run (e.g., `1`) For example: ```bash jf dotnet build --build-name=my-dotnet-app --build-number=1 ``` *** ## Important Notes * **dotnet vs nuget**: `jf dotnet` wraps the .NET CLI (which includes NuGet functionality). Use `jf dotnet` for .NET SDK-style projects and `jf nuget` for traditional NuGet-only projects. * **.NET commands**: All standard .NET CLI commands work (`restore`, `build`, `publish`, `test`, `pack`, and others). * **Build-info**: Use `--build-name` and `--build-number`, then publish with `jf rt build-publish`. ## CI/CD Example (GitHub Actions) ```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: 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 | | ------------------------------------------ | ----------------------------------------------------- | ----------------------------------------------------------------------------------- | | `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` | **Enable debug logging:** `export JFROG_CLI_LOG_LEVEL=DEBUG`
## Related Topics * [Build Tools Overview](/artifactory/docs/build-tool-commands) — Capabilities matrix and tool reference * [Native Mode](/artifactory/docs/native-mode) — Supported packages with Native Mode