Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This article applies to: ✔️ .NET 10.0.100 SDK and later versions
Name
dotnet tool exec - Downloads and invokes a .NET tool without permanently installing it.
Synopsis
dotnet tool exec <PACKAGE_NAME>[@<VERSION>]
[--allow-roll-forward] [-a|--arch <ARCHITECTURE>]
[--add-source <SOURCE>] [--configfile <FILE>] [--disable-parallel]
[--framework <FRAMEWORK>] [--ignore-failed-sources] [--interactive]
[--no-http-cache] [--prerelease]
[-v|--verbosity <LEVEL>]
[--] [<tool-arguments>...]
dotnet tool exec -h|--help
Description
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.
When you run dotnet tool exec, the command:
- 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.
- Downloads the specified package to the NuGet cache (if not already present).
- Invokes the tool with any provided arguments.
- Returns the tool's exit code.
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.
This command also exists in two other forms for easier use
dotnet dnx- A hidden alias fordotnet tool execthat is used as a way to easily implement thednxscript itselfdnx- A shell script that invokesdotnet dnxfrom the SDK. This script is provided by the installer and is available onPATH. It allows for very simple use of tools directly viadnx <toolname>.
Arguments
PACKAGE_NAMEThe NuGet package ID of the .NET tool to execute. You can optionally specify a version using the
@syntax, for exampledotnetsay@2.1.0.tool-argumentsArguments to pass to the tool being executed. Everything after
--is passed directly to the tool.
Options
--allow-roll-forwardAllow the tool to use a newer version of the .NET runtime if the runtime it targets isn't installed.
--add-source <SOURCE>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. You can control this through the use of NuGet package source mapping. For more information, see Package Source Mapping.
--configfile <FILE>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.
--disable-parallelDisables querying the configured NuGet feeds in parallel.
--ignore-failed-sourcesTreats package source failures as warnings.
--interactiveAllows the command to stop and wait for user input or action, for example, to complete authentication. This option defaults to
truewhen the command detects that it's being run directly by a user.--no-http-cacheDoesn't cache HTTP requests to the configured NuGet feeds.
--prereleaseAllows prerelease packages to be selected when resolving the version to install.
-v|--verbosity <LEVEL>Sets the verbosity level of the command. Allowed values are
q[uiet],m[inimal],n[ormal],d[etailed], anddiag[nostic]. The default isnormal.
-?|-h|--helpPrints out a description of how to use the command.
Examples
dotnet tool exec dotnetsayDownloads (if necessary) and runs the latest version of the
dotnetsaytool.dotnet tool exec dotnetsay@2.1.0Downloads (if necessary) and runs version 2.1.0 of the
dotnetsaytool.dotnet tool exec dotnetsay@2.*Downloads (if necessary) and runs the latest version of the
dotnetsaytool in the 2.x version range.dotnet tool exec dotnetsay -- Hello WorldRuns the
dotnetsaytool and passes "Hello World" as arguments to the tool.dotnet tool exec --add-source https://api.nuget.org/v3/index.json mytoolDownloads and runs
mytoolusing the specified NuGet source.
Comparison with other commands
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.
| Command | Purpose | Installation | Scope |
|---|---|---|---|
dotnet tool exec |
One-shot execution | None (cached only) | Temporary |
dotnet tool install -g |
Permanent global installation | Global | System-wide |
dotnet tool install |
Permanent local installation | Local manifest | Project |
dotnet tool run |
Run an already-installed local tool | Requires prior installation | Project |
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.