Add documentation for the dotnet build -t|--target option to dotnet-build.md.#53673
Add documentation for the dotnet build -t|--target option to dotnet-build.md.#53673classyk12 wants to merge 2 commits into
Conversation
Co-authored-by: Copilot <copilot@github.com>
|
@dotnet-policy-service agree |
|
|
||
| - **`-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). |
There was a problem hiding this comment.
| 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). |
| dotnet build -t:Clean | ||
| dotnet build -t:Rebuild | ||
| dotnet build -t:Clean;Build |
There was a problem hiding this comment.
| 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 |
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.
| [-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). |
| ```dotnetcli | ||
| dotnet build -t:Clean | ||
| dotnet build -t:Rebuild | ||
| dotnet build -t:Clean;Build | ||
| ``` |
| 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 | ||
| ``` |
| ```dotnetcli | ||
| dotnet build -p:Version=1.2.3.4 | ||
| ``` | ||
|
|
||
| - Run the `Clean` target to remove previous build outputs: | ||
|
|
||
| ```dotnetcli | ||
| dotnet build -t:Clean | ||
| ``` |
|
All changes have been applied now. @gfoidl |
| dotnet build -t:Clean | ||
| dotnet build -t:Rebuild | ||
| dotnet build -t:Build | ||
| ``` |
There was a problem hiding this comment.
Common targets include
Build(default),Clean, andRebuild
I wonder if there are better examples here. All these three are already handled by the dotnet CLI through dotnet build, dotnet build --no-incremental and dotnet clean.
Perhaps a better example in this doc would be to show how you can use -t to run custom targets. For example, just dotnet build -t:MyCustomTarget, where the name MyCustomTarget is clearly a placeholder for an actual value.
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