-
Notifications
You must be signed in to change notification settings - Fork 6k
Add new dotnet tool exec
command documentation and point existing docs to use dnx
as the top-level method
#48287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
baronfel
wants to merge
7
commits into
main
Choose a base branch
from
sdk-tools-rework
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+205
−14
Open
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8f14788
Add new `dotnet tool exec` command documentation and point existing d…
baronfel 388f768
resolve linting errors
baronfel 4b3d43d
fix invalid link
baronfel 96dc716
fix nuget package source mapping redirects
baronfel 230cbce
udpate dotnet-counters urls to be relative to silence suggestion from…
baronfel 6f279e5
Revert these two link suggestion fixes because they result in invalid…
baronfel 64da1f0
Apply suggestions from code review
baronfel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
--- | ||
title: dotnet tool exec command | ||
description: The dotnet tool exec command downloads and invokes a .NET tool in one step without permanent installation. | ||
ms.date: 09/06/2025 | ||
--- | ||
# dotnet tool exec | ||
|
||
**This article applies to:** ✔️ .NET 10.0.100-preview.6 SDK and later versions | ||
baronfel marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
## Name | ||
|
||
`dotnet tool exec` - Downloads and invokes a .NET tool without permanently installing it. | ||
|
||
## Synopsis | ||
|
||
```dotnetcli | ||
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. | ||
baronfel marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
When you run `dotnet tool exec`, the command: | ||
|
||
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 | ||
2. Downloads the specified package to the NuGet cache (if not already present) | ||
3. Invokes the tool with any provided arguments | ||
4. Returns the tool's exit code | ||
baronfel marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
`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 for `dotnet tool exec` that is mostly used to give us a point to easily implement the | ||
* `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>`. | ||
baronfel marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
## Arguments | ||
|
||
- **`PACKAGE_NAME`** | ||
|
||
The NuGet package ID of the .NET tool to execute. You can optionally specify a version using the `@` syntax, for example `[email protected]`. | ||
|
||
- **`tool-arguments`** | ||
|
||
Arguments to pass to the tool being executed. Everything after `--` is passed directly to the tool. | ||
|
||
## Options | ||
|
||
- **`--allow-roll-forward`** | ||
|
||
Allow 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. 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). | ||
baronfel marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
- **`--configfile <FILE>`** | ||
|
||
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). | ||
baronfel marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
- **`--disable-parallel`** | ||
|
||
Disables querying the configured NuGet feeds in parallel. | ||
|
||
- **`--ignore-failed-sources`** | ||
|
||
Treats package source failures as warnings. | ||
|
||
- **`--interactive`** | ||
|
||
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. | ||
baronfel marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
- **`--no-http-cache`** | ||
|
||
Doesn't cache HTTP requests to the configured NuGet feeds. | ||
|
||
- **`--prerelease`** | ||
|
||
Allows 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]`, and `diag[nostic]`. The default is `normal`. | ||
|
||
[!INCLUDE [help](../../../includes/cli-help.md)] | ||
|
||
## Examples | ||
|
||
- **`dotnet tool exec dotnetsay`** | ||
|
||
Downloads (if necessary) and runs the latest version of the `dotnetsay` tool. | ||
|
||
- **`dotnet tool exec [email protected]`** | ||
|
||
Downloads (if necessary) and runs version 2.1.0 of the `dotnetsay` tool. | ||
|
||
- **`dotnet tool exec dotnetsay@2.*`** | ||
|
||
Downloads (if necessary) and runs the latest version of the `dotnetsay` tool in the 2.x version range. | ||
|
||
- **`dotnet tool exec dotnetsay -- Hello World`** | ||
|
||
Runs the `dotnetsay` tool and passes "Hello World" as arguments to the tool. | ||
|
||
- **`dotnet tool exec --add-source https://api.nuget.org/v3/index.json mytool`** | ||
|
||
Downloads and runs `mytool` using 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, we think that `dotnet tool exec` provides a simpler and more flexible experience for most users. | ||
baronfel marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
| 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. | ||
|
||
## See also | ||
|
||
- [.NET tools](global-tools.md) | ||
- [dotnet tool install](dotnet-tool-install.md) | ||
- [dotnet tool run](dotnet-tool-run.md) | ||
- [Tutorial: Install and use a .NET global tool using the .NET CLI](global-tools-how-to-use.md) | ||
- [Tutorial: Install and use a .NET local tool using the .NET CLI](local-tools-how-to-use.md) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.