Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion docs/core/tools/dotnet-build.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Comment thread
gewarren marked this conversation as resolved.
[-v|--verbosity <LEVEL>] [--version-suffix <VERSION_SUFFIX>]

Expand Down Expand Up @@ -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
```
Comment thread
adegeo marked this conversation as resolved.
Comment on lines +163 to +167
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We could showcase the different styles

Suggested change
```dotnetcli
dotnet build -t:RunTests
dotnet build -t:GenerateApiClients
dotnet build -t:RunCodeGeneration
```
```dotnetcli
dotnet build -t:"Clean;RunTests"
dotnet build -t:Clean -t:GenerateApiClients
dotnet build -t:RunCodeGeneration


- [!INCLUDE [tl](includes/cli-tl.md)]

- [!INCLUDE [use-current-runtime](includes/cli-use-current-runtime.md)]
Expand Down Expand Up @@ -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
```
Loading