Add documentation for the dotnet build -t|--target option to dotnet-build.md.#53673
Open
classyk12 wants to merge 1 commit into
Open
Add documentation for the dotnet build -t|--target option to dotnet-build.md.#53673classyk12 wants to merge 1 commit into
classyk12 wants to merge 1 commit into
Conversation
Co-authored-by: Copilot <copilot@github.com>
Author
|
@dotnet-policy-service agree |
gfoidl
reviewed
May 11, 2026
|
|
||
| - **`-t|--target <TARGET>`** | ||
|
|
||
| Specifies one or more MSBuild targets to run during the build, instead of the default target. Multiple targets can be specified by separating them with a semicolon or by repeating the option. Corresponds to the MSBuild `-target` option. Common targets include `Build` (default), `Clean`, and `Rebuild`.. For more information about targets, see [MSBuild Targets](/visualstudio/msbuild/msbuild-targets). |
Member
There was a problem hiding this comment.
Suggested change
| Specifies one or more MSBuild targets to run during the build, instead of the default target. Multiple targets can be specified by separating them with a semicolon or by repeating the option. Corresponds to the MSBuild `-target` option. Common targets include `Build` (default), `Clean`, and `Rebuild`.. For more information about targets, see [MSBuild Targets](/visualstudio/msbuild/msbuild-targets). | |
| Specifies one or more MSBuild targets to run during the build, instead of the default target. Multiple targets can be specified by separating them with a semicolon or by repeating the option. Corresponds to the MSBuild `-target` option. Common targets include `Build` (default), `Clean`, and `Rebuild`. For more information about targets, see [MSBuild Targets](/visualstudio/msbuild/msbuild-targets). |
Comment on lines
+165
to
+167
| dotnet build -t:Clean | ||
| dotnet build -t:Rebuild | ||
| dotnet build -t:Clean;Build |
Member
There was a problem hiding this comment.
Suggested change
| dotnet build -t:Clean | |
| dotnet build -t:Rebuild | |
| dotnet build -t:Clean;Build | |
| dotnet build -t Clean | |
| dotnet build -t Rebuild | |
| dotnet build -t Clean;Build |
As given in the synopsis above. When the : is needed then L26 should be
-[-t|--target <TARGET>]
+[-t|--target:<TARGET>]| - Build the project and set version 1.2.3.4 as a build parameter using the `-p` [MSBuild option](#msbuild): | ||
|
|
||
| ```dotnetcli | ||
| ```dotnetcli |
| - Run the `Clean` target to remove previous build outputs: | ||
|
|
||
| ```dotnetcli | ||
| dotnet build -t:Clean |
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request updates the dotnet build command documentation to cover the -t|--target option, which lets you run specific MSBuild targets (such as Clean) instead of the default build target.
Changes:
- Added
-t|--targetto thedotnet buildsynopsis. - Added a new Options entry describing
-t|--targetand provided example invocations. - Added an Examples entry showing
dotnet build -t:Clean.
Comment on lines
24
to
27
| [-p|--property:<PROPERTYNAME>=<VALUE>] [-r|--runtime <RUNTIME_IDENTIFIER>] | ||
| [--sc|--self-contained] [--source <SOURCE>] | ||
| [-t|--target <TARGET>] | ||
| [--tl:[auto|on|off]] [ --ucr|--use-current-runtime] |
|
|
||
| The URI of the NuGet package source to use during the restore operation. | ||
|
|
||
| - **`-t|--target <TARGET>`** |
|
|
||
| - **`-t|--target <TARGET>`** | ||
|
|
||
| Specifies one or more MSBuild targets to run during the build, instead of the default target. Multiple targets can be specified by separating them with a semicolon or by repeating the option. Corresponds to the MSBuild `-target` option. Common targets include `Build` (default), `Clean`, and `Rebuild`.. For more information about targets, see [MSBuild Targets](/visualstudio/msbuild/msbuild-targets). |
Comment on lines
+164
to
+168
| ```dotnetcli | ||
| dotnet build -t:Clean | ||
| dotnet build -t:Rebuild | ||
| dotnet build -t:Clean;Build | ||
| ``` |
Comment on lines
+162
to
+168
| Specifies one or more MSBuild targets to run during the build, instead of the default target. Multiple targets can be specified by separating them with a semicolon or by repeating the option. Corresponds to the MSBuild `-target` option. Common targets include `Build` (default), `Clean`, and `Rebuild`.. For more information about targets, see [MSBuild Targets](/visualstudio/msbuild/msbuild-targets). | ||
|
|
||
| ```dotnetcli | ||
| dotnet build -t:Clean | ||
| dotnet build -t:Rebuild | ||
| dotnet build -t:Clean;Build | ||
| ``` |
Comment on lines
+218
to
+226
| ```dotnetcli | ||
| dotnet build -p:Version=1.2.3.4 | ||
| ``` | ||
|
|
||
| - Run the `Clean` target to remove previous build outputs: | ||
|
|
||
| ```dotnetcli | ||
| dotnet build -t:Clean | ||
| ``` |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add documentation for the dotnet build -t|--target option to dotnet-build.md
Updated the dotnet build synopsis to include [-t|--target:]
Added a new options entry for -t|--target:
Included a short explanation and examples for using a specific MSBuild target
Added an example in the Examples section showing dotnet build -t:Clean
The dotnet build command accepts -t/--target, but the existing docs did not document it. This resolves missing documentation reported in issue #53658.
Verified the option syntax matches existing CLI documentation style
Confirmed the added examples are consistent with other dotnet build examples
Internal previews