-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Add documentation for the dotnet build -t|--target option to dotnet-build.md. #53673
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,6 +3,7 @@ title: dotnet build command | |||||||||||||
| description: The dotnet build command builds a project and all of its dependencies. | ||||||||||||||
| ms.date: 09/24/2025 | ||||||||||||||
| --- | ||||||||||||||
|
|
||||||||||||||
| # dotnet build | ||||||||||||||
|
|
||||||||||||||
| **This article applies to:** ✔️ .NET 6 SDK and later versions | ||||||||||||||
|
|
@@ -22,6 +23,7 @@ dotnet build [<PROJECT>|<SOLUTION>|<FILE>] [-a|--arch <ARCHITECTURE>] | |||||||||||||
| [--no-self-contained] [-o|--output <OUTPUT_DIRECTORY>] [--os <OS>] | ||||||||||||||
| [-p|--property:<PROPERTYNAME>=<VALUE>] [-r|--runtime <RUNTIME_IDENTIFIER>] | ||||||||||||||
| [--sc|--self-contained] [--source <SOURCE>] | ||||||||||||||
| [-t|--target <TARGET>] | ||||||||||||||
| [--tl:[auto|on|off]] [ --ucr|--use-current-runtime] | ||||||||||||||
| [-v|--verbosity <LEVEL>] [--version-suffix <VERSION_SUFFIX>] | ||||||||||||||
|
|
||||||||||||||
|
|
@@ -155,6 +157,16 @@ Running `dotnet build` is equivalent to running `dotnet msbuild -restore`; howev | |||||||||||||
|
|
||||||||||||||
| The URI of the NuGet package source to use during the restore operation. | ||||||||||||||
|
|
||||||||||||||
| - **`-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 | ||||||||||||||
|
Comment on lines
+165
to
+167
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
As given in the synopsis above. When the -[-t|--target <TARGET>]
+[-t|--target:<TARGET>] |
||||||||||||||
| ``` | ||||||||||||||
|
|
||||||||||||||
| - [!INCLUDE [tl](includes/cli-tl.md)] | ||||||||||||||
|
|
||||||||||||||
| - [!INCLUDE [use-current-runtime](includes/cli-use-current-runtime.md)] | ||||||||||||||
|
|
@@ -203,6 +215,12 @@ Running `dotnet build` is equivalent to running `dotnet msbuild -restore`; howev | |||||||||||||
|
|
||||||||||||||
| - Build the project and set version 1.2.3.4 as a build parameter using the `-p` [MSBuild option](#msbuild): | ||||||||||||||
|
|
||||||||||||||
| ```dotnetcli | ||||||||||||||
| ```dotnetcli | ||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: undo |
||||||||||||||
| dotnet build -p:Version=1.2.3.4 | ||||||||||||||
| ``` | ||||||||||||||
|
|
||||||||||||||
| - Run the `Clean` target to remove previous build outputs: | ||||||||||||||
|
|
||||||||||||||
| ```dotnetcli | ||||||||||||||
| dotnet build -t:Clean | ||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as #53673 (comment) |
||||||||||||||
| ``` | ||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.