-
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
Open
classyk12
wants to merge
4
commits into
dotnet:main
Choose a base branch
from
classyk12:issue/53658-add-target-option-docs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+18
−1
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| 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 | ||||||||||||||||||||
|
|
@@ -21,7 +22,7 @@ dotnet build [<PROJECT>|<SOLUTION>|<FILE>] [-a|--arch <ARCHITECTURE>] | |||||||||||||||||||
| [--no-dependencies] [--no-incremental] [--no-restore] [--nologo] | ||||||||||||||||||||
| [--no-self-contained] [-o|--output <OUTPUT_DIRECTORY>] [--os <OS>] | ||||||||||||||||||||
| [-p|--property:<PROPERTYNAME>=<VALUE>] [-r|--runtime <RUNTIME_IDENTIFIER>] | ||||||||||||||||||||
| [--sc|--self-contained] [--source <SOURCE>] | ||||||||||||||||||||
| [--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 +156,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. Specify multiple targets by separating them with a semicolon or comma, or by repeating the option for each target. Corresponds to the MSBuild -target option. Common targets include Build (default), Clean, and Rebuild. For more information, see MSBuild Targets. | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ```dotnetcli | ||||||||||||||||||||
| dotnet build -t:"Clean;RunTests" | ||||||||||||||||||||
| dotnet build -t:Clean -t:GenerateApiClients | ||||||||||||||||||||
| dotnet build -t:RunCodeGeneration | ||||||||||||||||||||
| ``` | ||||||||||||||||||||
|
adegeo marked this conversation as resolved.
Comment on lines
+163
to
+167
Contributor
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. We could showcase the different styles
Suggested change
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| - [!INCLUDE [tl](includes/cli-tl.md)] | ||||||||||||||||||||
|
|
||||||||||||||||||||
| - [!INCLUDE [use-current-runtime](includes/cli-use-current-runtime.md)] | ||||||||||||||||||||
|
|
@@ -206,3 +217,9 @@ Running `dotnet build` is equivalent to running `dotnet msbuild -restore`; howev | |||||||||||||||||||
| ```dotnetcli | ||||||||||||||||||||
| dotnet build -p:Version=1.2.3.4 | ||||||||||||||||||||
| ``` | ||||||||||||||||||||
|
|
||||||||||||||||||||
| - Run the `Clean` target to remove previous build outputs: | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ```dotnetcli | ||||||||||||||||||||
| dotnet build -t:Clean | ||||||||||||||||||||
| ``` | ||||||||||||||||||||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.