|
| 1 | +--- |
| 2 | +title: dotnet tool exec command |
| 3 | +description: The dotnet tool exec command downloads and invokes a .NET tool in one step without permanent installation. |
| 4 | +ms.date: 09/06/2025 |
| 5 | +--- |
| 6 | +# dotnet tool exec |
| 7 | + |
| 8 | +**This article applies to:** ✔️ .NET 10.0.100-preview.6 SDK and later versions |
| 9 | + |
| 10 | +## Name |
| 11 | + |
| 12 | +`dotnet tool exec` - Downloads and invokes a .NET tool without permanently installing it. |
| 13 | + |
| 14 | +## Synopsis |
| 15 | + |
| 16 | +```dotnetcli |
| 17 | +dotnet tool exec <PACKAGE_NAME>[@<VERSION>] |
| 18 | + [--allow-roll-forward] [-a|--arch <ARCHITECTURE>] |
| 19 | + [--add-source <SOURCE>] [--configfile <FILE>] [--disable-parallel] |
| 20 | + [--framework <FRAMEWORK>] [--ignore-failed-sources] [--interactive] |
| 21 | + [--no-http-cache] [--prerelease] |
| 22 | + [-v|--verbosity <LEVEL>] |
| 23 | + [--] [<tool-arguments>...] |
| 24 | +
|
| 25 | +dotnet tool exec -h|--help |
| 26 | +``` |
| 27 | + |
| 28 | +## Description |
| 29 | + |
| 30 | +The `dotnet tool exec` command provides a one-shot tool invocation mode for .NET Tools. It automatically downloads the specified tool package to the NuGet cache and invokes it without modifying your system PATH or requiring permanent installation. |
| 31 | + |
| 32 | +When you run `dotnet tool exec`, the command: |
| 33 | + |
| 34 | +1. Checks the version (or version range) you specify (or the latest version if none is specified) against your configured NuGet feeds to decide which package to download |
| 35 | +2. Downloads the specified package to the NuGet cache (if not already present) |
| 36 | +3. Invokes the tool with any provided arguments |
| 37 | +4. Returns the tool's exit code |
| 38 | + |
| 39 | +The command interacts with local tool configurations seamlessly: |
| 40 | +- If a local tool manifest exists and contains the specified tool, it uses that version |
| 41 | +- Otherwise, it downloads the latest version or the version you specify |
| 42 | + |
| 43 | +This command is ideal for: |
| 44 | +- Running tools without permanent installation |
| 45 | +- Trying out tools before deciding to install them |
| 46 | +- Running tools in CI/CD pipelines without setup steps |
| 47 | +- Using different versions of tools for different projects |
| 48 | +- Using the same mechanism across global and local tools |
| 49 | + |
| 50 | +This command also exists in two other forms for easier use |
| 51 | +* `dotnet dnx` - a hidden alias for `dotnet tool exec` that is mostly used to give us a point to easily implement the |
| 52 | +* `dnx` - a shell script that invokes `dotnet dnx` from the SDK. This script is provided by the installer and is available on the PATH. It allows for very simple use of Tools directly via `dnx <toolname>`. |
| 53 | + |
| 54 | +## Arguments |
| 55 | + |
| 56 | +- **`PACKAGE_NAME`** |
| 57 | + |
| 58 | + The NuGet package ID of the .NET tool to execute. You can optionally specify a version using the `@` syntax, for example `[email protected]`. |
| 59 | + |
| 60 | +- **`tool-arguments`** |
| 61 | + |
| 62 | + Arguments to pass to the tool being executed. Everything after `--` is passed directly to the tool. |
| 63 | + |
| 64 | +## Options |
| 65 | + |
| 66 | +- **`--allow-roll-forward`** |
| 67 | + |
| 68 | + Allow the tool to use a newer version of the .NET runtime if the runtime it targets isn't installed. |
| 69 | + |
| 70 | +- **`--add-source <SOURCE>`** |
| 71 | + |
| 72 | + Adds an additional NuGet package source to use during installation. Feeds are accessed in parallel, not in a fallback cascade sequence. If the same package and version is available in multiple feeds, the fastest feed wins. See [What happens when a NuGet package is installed](/nuget/concepts/package-installation-process#what-happens-when-a-nuget-package-is-installed). This can be controlled through the use of NuGet Package Source Mapping. For more information, see [Package Source Mapping](~/nuget/consume-packages/package-source-mapping). |
| 73 | + |
| 74 | +- **`--configfile <FILE>`** |
| 75 | + |
| 76 | + The NuGet configuration file (*nuget.config*) to use. If specified, only the settings from this file will be used. If not specified, the hierarchy of configuration files from the current directory will be used. For more information, see [Common NuGet Configurations](~/nuget/consume-packages/configuring-nuget-behavior). |
| 77 | + |
| 78 | +- **`--disable-parallel`** |
| 79 | + |
| 80 | + Disables querying the configured NuGet feeds in parallel. |
| 81 | + |
| 82 | +- **`--ignore-failed-sources`** |
| 83 | + |
| 84 | + Treats package source failures as warnings. |
| 85 | + |
| 86 | +- **`--interactive`** |
| 87 | + |
| 88 | + Allows the command to stop and wait for user input or action. For example, to complete authentication. This is defaulted to `true` when the command detects that it's being run directly by a user. |
| 89 | + |
| 90 | +- **`--no-http-cache`** |
| 91 | + |
| 92 | + Doesn't cache HTTP requests to the configured NuGet feeds. |
| 93 | + |
| 94 | +- **`--prerelease`** |
| 95 | + |
| 96 | + Allows prerelease packages to be selected when resolving the version to install. |
| 97 | + |
| 98 | +- **`-v|--verbosity <LEVEL>`** |
| 99 | + |
| 100 | + Sets the verbosity level of the command. Allowed values are `q[uiet]`, `m[inimal]`, `n[ormal]`, `d[etailed]`, and `diag[nostic]`. The default is `normal`. |
| 101 | + |
| 102 | +[!INCLUDE [help](../../../includes/cli-help.md)] |
| 103 | + |
| 104 | +## Examples |
| 105 | + |
| 106 | +- **`dotnet tool exec dotnetsay`** |
| 107 | + |
| 108 | + Downloads (if necessary) and runs the latest version of the `dotnetsay` tool. |
| 109 | + |
| 110 | +- **`dotnet tool exec [email protected]`** |
| 111 | + |
| 112 | + Downloads (if necessary) and runs version 2.1.0 of the `dotnetsay` tool. |
| 113 | + |
| 114 | +- **`dotnet tool exec dotnetsay@2.*`** |
| 115 | + |
| 116 | + Downloads (if necessary) and runs the latest version of the `dotnetsay` tool in the 2.x version range. |
| 117 | + |
| 118 | +- **`dotnet tool exec dotnetsay -- Hello World`** |
| 119 | + |
| 120 | + Runs the `dotnetsay` tool and passes "Hello World" as arguments to the tool. |
| 121 | + |
| 122 | +- **`dotnet tool exec --add-source https://api.nuget.org/v3/index.json mytool`** |
| 123 | + |
| 124 | + Downloads and runs `mytool` using the specified NuGet source. |
| 125 | + |
| 126 | +## Comparison with other commands |
| 127 | + |
| 128 | +This command is intended to be a unified way to work with .NET Tools. While the previously-available Tool installation commands remain available, we think that `dotnet tool exec` provides a simpler and more flexible experience for most users. |
| 129 | + |
| 130 | +| Command | Purpose | Installation | Scope | |
| 131 | +|---------|---------|--------------|-------| |
| 132 | +| `dotnet tool exec` | One-shot execution | None (cached only) | Temporary | |
| 133 | +| `dotnet tool install -g` | Permanent global installation | Global | System-wide | |
| 134 | +| `dotnet tool install` | Permanent local installation | Local manifest | Project | |
| 135 | +| `dotnet tool run` | Run an already-installed local tool | Requires prior installation | Project | |
| 136 | + |
| 137 | +The `dotnet tool install -g` command does still serve an important purpose for users who want to permanently install a tool. However, for users who want to try out a tool or run it in a CI/CD pipeline, `dotnet tool exec` is often a better fit. |
| 138 | + |
| 139 | +## See also |
| 140 | + |
| 141 | +- [.NET tools](global-tools.md) |
| 142 | +- [dnx command](dnx.md) |
| 143 | +- [dotnet tool install](dotnet-tool-install.md) |
| 144 | +- [dotnet tool run](dotnet-tool-run.md) |
| 145 | +- [Tutorial: Install and use a .NET global tool using the .NET CLI](global-tools-how-to-use.md) |
| 146 | +- [Tutorial: Install and use a .NET local tool using the .NET CLI](local-tools-how-to-use.md) |
0 commit comments