|
| 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 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 | +`dotnet tool exec` works seamlessly with both global and local tools. If you have a local tool manifest available, it uses the manifest to determine which version of the tool to run. |
| 40 | + |
| 41 | +This command also exists in two other forms for easier use |
| 42 | + |
| 43 | +* `dotnet dnx` - A hidden alias for `dotnet tool exec` that is used as a way to easily implement the `dnx` script itself |
| 44 | +* `dnx` - A shell script that invokes `dotnet dnx` from the SDK. This script is provided by the installer and is available on `PATH`. It allows for very simple use of tools directly via `dnx <toolname>`. |
| 45 | + |
| 46 | +## Arguments |
| 47 | + |
| 48 | +- **`PACKAGE_NAME`** |
| 49 | + |
| 50 | + The NuGet package ID of the .NET tool to execute. You can optionally specify a version using the `@` syntax, for example `[email protected]`. |
| 51 | + |
| 52 | +- **`tool-arguments`** |
| 53 | + |
| 54 | + Arguments to pass to the tool being executed. Everything after `--` is passed directly to the tool. |
| 55 | + |
| 56 | +## Options |
| 57 | + |
| 58 | +- **`--allow-roll-forward`** |
| 59 | + |
| 60 | + Allow the tool to use a newer version of the .NET runtime if the runtime it targets isn't installed. |
| 61 | + |
| 62 | +- **`--add-source <SOURCE>`** |
| 63 | + |
| 64 | + 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. For more information, see [What happens when a NuGet package is installed](/nuget/concepts/package-installation-process#what-happens-when-a-nuget-package-is-installed). You can control this through the use of NuGet package source mapping. For more information, see [Package Source Mapping](/nuget/consume-packages/package-source-mapping). |
| 65 | + |
| 66 | +- **`--configfile <FILE>`** |
| 67 | + |
| 68 | + The NuGet configuration file (*nuget.config*) to use. If specified, only the settings from this file are used. If not specified, the hierarchy of configuration files from the current directory are used. For more information, see [Common NuGet Configurations](/nuget/consume-packages/configuring-nuget-behavior). |
| 69 | + |
| 70 | +- **`--disable-parallel`** |
| 71 | + |
| 72 | + Disables querying the configured NuGet feeds in parallel. |
| 73 | + |
| 74 | +- **`--ignore-failed-sources`** |
| 75 | + |
| 76 | + Treats package source failures as warnings. |
| 77 | + |
| 78 | +- **`--interactive`** |
| 79 | + |
| 80 | + Allows the command to stop and wait for user input or action, for example, to complete authentication. This option defaults to `true` when the command detects that it's being run directly by a user. |
| 81 | + |
| 82 | +- **`--no-http-cache`** |
| 83 | + |
| 84 | + Doesn't cache HTTP requests to the configured NuGet feeds. |
| 85 | + |
| 86 | +- **`--prerelease`** |
| 87 | + |
| 88 | + Allows prerelease packages to be selected when resolving the version to install. |
| 89 | + |
| 90 | +- **`-v|--verbosity <LEVEL>`** |
| 91 | + |
| 92 | + 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`. |
| 93 | + |
| 94 | +[!INCLUDE [help](../../../includes/cli-help.md)] |
| 95 | + |
| 96 | +## Examples |
| 97 | + |
| 98 | +- **`dotnet tool exec dotnetsay`** |
| 99 | + |
| 100 | + Downloads (if necessary) and runs the latest version of the `dotnetsay` tool. |
| 101 | + |
| 102 | +- **`dotnet tool exec [email protected]`** |
| 103 | + |
| 104 | + Downloads (if necessary) and runs version 2.1.0 of the `dotnetsay` tool. |
| 105 | + |
| 106 | +- **`dotnet tool exec dotnetsay@2.*`** |
| 107 | + |
| 108 | + Downloads (if necessary) and runs the latest version of the `dotnetsay` tool in the 2.x version range. |
| 109 | + |
| 110 | +- **`dotnet tool exec dotnetsay -- Hello World`** |
| 111 | + |
| 112 | + Runs the `dotnetsay` tool and passes "Hello World" as arguments to the tool. |
| 113 | + |
| 114 | +- **`dotnet tool exec --add-source https://api.nuget.org/v3/index.json mytool`** |
| 115 | + |
| 116 | + Downloads and runs `mytool` using the specified NuGet source. |
| 117 | + |
| 118 | +## Comparison with other commands |
| 119 | + |
| 120 | +This command is intended to be a unified way to work with .NET Tools. While the previously available tool installation commands remain available, `dotnet tool exec` provides a simpler and more flexible experience for most users. |
| 121 | + |
| 122 | +| Command | Purpose | Installation | Scope | |
| 123 | +|---------|---------|--------------|-------| |
| 124 | +| `dotnet tool exec` | One-shot execution | None (cached only) | Temporary | |
| 125 | +| `dotnet tool install -g` | Permanent global installation | Global | System-wide | |
| 126 | +| `dotnet tool install` | Permanent local installation | Local manifest | Project | |
| 127 | +| `dotnet tool run` | Run an already-installed local tool | Requires prior installation | Project | |
| 128 | + |
| 129 | +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. |
| 130 | + |
| 131 | +## See also |
| 132 | + |
| 133 | +- [.NET tools](global-tools.md) |
| 134 | +- [dotnet tool install](dotnet-tool-install.md) |
| 135 | +- [dotnet tool run](dotnet-tool-run.md) |
| 136 | +- [Tutorial: Install and use a .NET global tool using the .NET CLI](global-tools-how-to-use.md) |
| 137 | +- [Tutorial: Install and use a .NET local tool using the .NET CLI](local-tools-how-to-use.md) |
0 commit comments