Skip to content

Add documentation for the dotnet build -t|--target option to dotnet-build.md.#53673

Open
classyk12 wants to merge 1 commit intodotnet:mainfrom
classyk12:issue/53658-add-target-option-docs
Open

Add documentation for the dotnet build -t|--target option to dotnet-build.md.#53673
classyk12 wants to merge 1 commit intodotnet:mainfrom
classyk12:issue/53658-add-target-option-docs

Conversation

@classyk12
Copy link
Copy Markdown

@classyk12 classyk12 commented May 10, 2026

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

📄 File 🔗 Preview link
docs/core/tools/dotnet-build.md dotnet build

Co-authored-by: Copilot <copilot@github.com>
@classyk12 classyk12 requested review from a team and meaghanlewis as code owners May 10, 2026 18:08
@dotnetrepoman dotnetrepoman Bot added this to the May 2026 milestone May 10, 2026
@dotnet-policy-service dotnet-policy-service Bot added dotnet-fundamentals/svc dotnet-cli/subsvc community-contribution Indicates PR is created by someone from the .NET community. labels May 10, 2026
@classyk12
Copy link
Copy Markdown
Author

@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).
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: undo

- Run the `Clean` target to remove previous build outputs:

```dotnetcli
dotnet build -t:Clean
Copy link
Copy Markdown
Member

@gfoidl gfoidl May 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Indicates PR is created by someone from the .NET community. dotnet-cli/subsvc dotnet-fundamentals/svc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants