From b68d6375ba87d0956b4f522eb3815b99ee0b21ee Mon Sep 17 00:00:00 2001 From: Faith Sodipe Date: Sun, 10 May 2026 18:58:13 +0100 Subject: [PATCH 1/2] documented -t for build options Co-authored-by: Copilot --- docs/core/tools/dotnet-build.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/docs/core/tools/dotnet-build.md b/docs/core/tools/dotnet-build.md index 6d35a9bb5a48e..1b487fc32536d 100644 --- a/docs/core/tools/dotnet-build.md +++ b/docs/core/tools/dotnet-build.md @@ -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 [||] [-a|--arch ] [--no-self-contained] [-o|--output ] [--os ] [-p|--property:=] [-r|--runtime ] [--sc|--self-contained] [--source ] + [-t|--target ] [--tl:[auto|on|off]] [ --ucr|--use-current-runtime] [-v|--verbosity ] [--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 `** + + 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 + ``` + - [!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 dotnet build -p:Version=1.2.3.4 ``` + +- Run the `Clean` target to remove previous build outputs: + + ```dotnetcli + dotnet build -t:Clean + ``` From 4f176ed59a6edfdc2587071727343570e81dbf1a Mon Sep 17 00:00:00 2001 From: Faith Sodipe Date: Mon, 11 May 2026 22:24:10 +0100 Subject: [PATCH 2/2] made code changes based on PR reviews --- docs/core/tools/dotnet-build.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/core/tools/dotnet-build.md b/docs/core/tools/dotnet-build.md index 1b487fc32536d..c1a08ac6a69fe 100644 --- a/docs/core/tools/dotnet-build.md +++ b/docs/core/tools/dotnet-build.md @@ -23,7 +23,7 @@ dotnet build [||] [-a|--arch ] [--no-self-contained] [-o|--output ] [--os ] [-p|--property:=] [-r|--runtime ] [--sc|--self-contained] [--source ] - [-t|--target ] + [-t|--target:] [--tl:[auto|on|off]] [ --ucr|--use-current-runtime] [-v|--verbosity ] [--version-suffix ] @@ -157,15 +157,15 @@ 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 `** +- **`-t|--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). + 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 -t:Clean + dotnet build -t:Rebuild + dotnet build -t:Build + ``` - [!INCLUDE [tl](includes/cli-tl.md)] @@ -215,12 +215,12 @@ dotnet build -t:Clean;Build - Build the project and set version 1.2.3.4 as a build parameter using the `-p` [MSBuild option](#msbuild): - ```dotnetcli + ```dotnetcli dotnet build -p:Version=1.2.3.4 ``` - Run the `Clean` target to remove previous build outputs: - ```dotnetcli - dotnet build -t:Clean - ``` + ```dotnetcli + dotnet build -t:Clean + ```