Skip to content

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

Open
classyk12 wants to merge 2 commits into
dotnet: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 2 commits into
dotnet: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

Comment thread docs/core/tools/dotnet-build.md Outdated

- **`-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 thread docs/core/tools/dotnet-build.md Outdated
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>]

Comment thread docs/core/tools/dotnet-build.md Outdated
- 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

Comment thread docs/core/tools/dotnet-build.md Outdated
- 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.

@gewarren gewarren linked an issue May 11, 2026 that may be closed by this pull request
@gewarren gewarren requested a review from Copilot May 11, 2026 17:10
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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|--target to the dotnet build synopsis.
  • Added a new Options entry describing -t|--target and 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]
Comment thread docs/core/tools/dotnet-build.md Outdated

The URI of the NuGet package source to use during the restore operation.

- **`-t|--target <TARGET>`**
Comment thread docs/core/tools/dotnet-build.md Outdated

- **`-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 thread docs/core/tools/dotnet-build.md Outdated
Comment on lines +164 to +168
```dotnetcli
dotnet build -t:Clean
dotnet build -t:Rebuild
dotnet build -t:Clean;Build
```
Comment thread docs/core/tools/dotnet-build.md Outdated
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 thread docs/core/tools/dotnet-build.md Outdated
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
```
@classyk12
Copy link
Copy Markdown
Author

All changes have been applied now. @gfoidl

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.

"dotnet build -t" option is not documented

3 participants