Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
ac9db59
Add how to article for updating tasks
ghogen Sep 26, 2025
e55d9dd
Add sample code
ghogen Mar 6, 2026
44fed9c
Expand MSBuild multithreaded task migration guide
ghogen Apr 3, 2026
2b82af4
Add environment variable example to BuildCommentTask sample
ghogen Apr 3, 2026
2e52871
Keep static field with Interlocked.Increment in migrated example
ghogen Apr 3, 2026
ccc6df8
Use naive ++ in before sample to show actual thread-safety bug
ghogen Apr 3, 2026
5ca5812
Rewrite static fields section with three-level progression
ghogen Apr 3, 2026
4333c21
Acknowledge pre-existing static state issues with node reuse
ghogen Apr 3, 2026
c5484ab
Clarify file type targeting and add MSBuild usage example
ghogen Apr 3, 2026
3c1b082
Default CommentPrefix to empty string, add plain text usage example
ghogen Apr 3, 2026
39e7f9b
Update MSBuild version requirement from 18.0 to 18.4
ghogen Apr 3, 2026
5d0503f
Add -mt command-line switch documentation
ghogen Apr 4, 2026
0af738b
Add code comment about text-file responsibility for TargetFiles
ghogen Apr 4, 2026
c3780be
Add file contention guidance for multithreaded builds
ghogen Apr 4, 2026
7c992e0
Add links to .NET file I/O and threading guidance
ghogen Apr 4, 2026
db600c1
Update docs/msbuild/update-task-multithreaded.md
ghogen Apr 4, 2026
2c0bfc0
Clarify TaskEnvironment thread-safety note as advanced scenario
ghogen Apr 4, 2026
383ede6
Merge branch 'main' of github.com:MicrosoftDocs/visualstudio-docs-pr …
ghogen Apr 23, 2026
2b9a937
Evaluate and remove redundancy
ghogen Apr 23, 2026
7a0111e
No abstract class, remove all refs
ghogen Apr 24, 2026
fba2079
ITaskEnvironment > TaskEnvironment
ghogen Apr 24, 2026
11633e8
Apply suggestion from @AR-May
ghogen Apr 30, 2026
aad1667
incorporate feedback
ghogen Apr 30, 2026
4303a9f
Merge branch 'task-multithreaded-updates' of github.com:ghogen/vsdocs…
ghogen Apr 30, 2026
7de970d
incorp feedback
ghogen Apr 30, 2026
1d9b4fb
Restructure TaskEnvironment.Fallback guidance
ghogen Apr 30, 2026
59e2b89
Use present tense and avoid "old" vs "new"
ghogen Apr 30, 2026
70bb121
Apply suggestions from code review
ghogen May 6, 2026
ed30ef4
update code to remove date
ghogen May 6, 2026
e52f07e
Merge branch 'task-multithreaded-updates' of github.com:ghogen/vsdocs…
ghogen May 6, 2026
508cbeb
incorp feedback , update env vars section
ghogen May 6, 2026
c817a21
incorp more feedback
ghogen May 6, 2026
9fe7851
add note about experimental status
ghogen May 6, 2026
40ca181
fix typo space
ghogen May 6, 2026
194dd71
Delete Roslyn analyzer note
ghogen May 7, 2026
99e98da
Acrolinx and dashes
ghogen May 7, 2026
56bd7b9
note about thread-safety of RegisterTaskObjects
ghogen May 7, 2026
6e46980
Merge pull request #14354 from ghogen/task-multithreaded-updates
JamesJBarnett May 12, 2026
4068d4c
Add VS2026 screenshot
cdpark May 12, 2026
b8fe212
PR review: Fix spelling of 'hierarchal' to 'hierarchical'
AnnaMHuff May 12, 2026
f582f20
Merge pull request #15383 from cdpark/replace-screenshots-vs2026-1
AnnaMHuff May 12, 2026
733dfcb
Merge pull request #15386 from MicrosoftDocs/main
learn-build-service-prod[bot] May 12, 2026
3638fe6
Merging changes synced from https://github.com/MicrosoftDocs/visualst…
May 12, 2026
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
45 changes: 44 additions & 1 deletion docs/msbuild/msbuild-command-line-reference.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: MSBuild Command-Line Reference
description: Learn how to use MSBuild.exe command line to build a project or solution file, and several switches you can include.
ms.date: 06/06/2024
ms.date: 04/03/2026
ms.topic: reference
dev_langs:
- VB
Expand Down Expand Up @@ -40,6 +40,46 @@ The first column in the following table shows a long and short form of each swit

Square brackets `[]` indicate optional parts, and curly braces `{}`indicate user-supplied values.

:::moniker range="vs-2022"

|Switch|Description|
|------------|-----------------|
|`-detailedSummary[:{True or False}]`<br/><br/>`-ds[:{True or False}]`|If `True`, show detailed information at the end of the build log about the configurations that were built and how they were scheduled to nodes.|
|`-getItem:{itemName,...}`|Write out the value of the item or items after evaluation, without executing the build, or if either the `-targets` option or the `-getTargetResult` option is used, write out the values after the build.|
|`-getProperty:{propertyName,...}`|Write out the value of the property or properties after evaluation, without executing the build, or if either the `-targets` option or the `-getTargetResult` option is used, write out the values after the build.|
|`-getTargetResult:{targetName,...}`|Write out the output values of the specified targets.|
|`-graphBuild[:{True or False}]`<br/><br/>`-graph[:{True or False}]`|Causes MSBuild to construct and build a project graph. Constructing a graph involves identifying project references to form dependencies. Building that graph involves attempting to build project references prior to the projects that reference them, differing from traditional MSBuild scheduling. Requires MSBuild 16 or later.|
|`-help`<br/><br/>`/?` or `-h`|Display usage information. The following command is an example:<br /><br /> `msbuild.exe -?`|
|`-ignoreProjectExtensions: {extensions}`<br/><br/>`-ignore: {extensions}`|Ignore the specified extensions when determining which project file to build. Use a semicolon or a comma to separate multiple extensions, as the following example shows:<br /><br /> `-ignoreprojectextensions:.vcproj,.sln`|
|`-inputResultsCaches[:{cacheFile; ...}]`<br/><br/>`-irc[:{cacheFile; ...}]`|Semicolon separated list of input cache files that MSBuild will read build results from. If `-isolateProjects` is set to `False`, this sets it to `True`.|
|`-interactive[:{True or False}]`|Indicates that actions in the build are allowed to interact with the user. Don't use this argument in an automated scenario where interactivity is not expected. Specifying `-interactive` is the same as specifying `-interactive:true`. Use the parameter to override a value that comes from a response file.|
|`-isolateProjects[:{True, MessageUponIsolationViolation, False}]`<br/><br/>`-isolate[:{True, MessageUponIsolationViolation, False}]`|Causes MSBuild to build each project in isolation. When set to `MessageUponIsolationViolation` (or its short form `Message`), only the results from top-level targets are serialized if the `-outputResultsCache` switch is supplied. This option is to mitigate the chances of an isolation-violating target on a dependency project using incorrect state due to its dependency on a cached target whose side effects wouldn't be taken into account. (For example, the definition of a property.) This mode is more restrictive, as it requires that the project graph be statically discoverable at evaluation time, but can improve scheduling and reduce memory overhead when building a large set of projects.|
|`-lowPriority[:{True or False}]`<br/><br/>`-low[:{True or False}]`|Causes MSBuild to run at low process priority. Specifying `-lowPriority` is the same as specifying `-lowPriority:True`.|
|`-maxCpuCount[:{number}]`<br/><br/>`-m[:{number}]`|Specifies the maximum number of concurrent processes to use when building. If you don't include this switch, the default value is 1. If you include this switch without specifying a value, MSBuild uses up to the number of processors in the computer. For more information, see [Building multiple projects in parallel](../msbuild/building-multiple-projects-in-parallel-with-msbuild.md).<br /><br /> The following example instructs MSBuild to build using three MSBuild processes, which allows three projects to build at the same time:<br /><br /> `msbuild myproject.proj -maxcpucount:3`|
|`-noAutoResponse`<br/><br/>`-noautorsp`|Don't include any *MSBuild.rsp* or *Directory.Build.rsp* files automatically.|
|`-nodeReuse:{value}`<br/><br/>`-nr:{value}`|Enable or disable the reuse of MSBuild nodes. You can specify the following values:<br /><br /> - **True**. Nodes remain after the build finishes so that subsequent builds can use them (default).<br />- **False**. Nodes don't remain after the build completes.<br /><br /> A node corresponds to a project that's executing. If you include the `-maxcpucount` switch, multiple nodes can execute concurrently.|
|`-nologo`|Don't display the startup banner or the copyright message.|
|<a name="preprocess"></a> `-preprocess[:{filepath}]`<br/><br/>`-pp[:{filepath}]`|Create a single, aggregated project file by inlining all the files that would be imported during a build, with their boundaries marked. You can use this switch to more easily determine which files are being imported, from where the files are being imported, and which files contribute to the build. When you use this switch, the project isn't built.<br /><br /> If you specify a `filepath`, the aggregated project file is output to the file. Otherwise, the output appears in the console window.<br /><br /> For information about how to use the `Import` element to insert a project file into another project file, see [Import element (MSBuild)](../msbuild/import-element-msbuild.md) and [How to: Use the same target in multiple project files](../msbuild/how-to-use-the-same-target-in-multiple-project-files.md).|
|`-outputResultsCache[:{cacheFile}]`<br/><br/>`-orc[:{cacheFile}]`|Output cache file where MSBuild writes the contents of its build result caches at the end of the build. If `-isolateProjects` is set to `False`, this sets it to `True`.|
|`profileEvaluation:{file}`|Profiles MSBuild evaluation and writes the result to the specified file. If the extension of the specified file is '.md', the result is generated in Markdown format. Otherwise, a tab-separated file is produced.|
|`-property:{name}={value}`<br/><br/>`-p:{name}={value}`|Set or override the specified project-level properties, where `name` is the property name and `value` is the property value. Specify each property separately, or use a semicolon or comma to separate multiple properties, as the following example shows:<br /><br /> `-property:WarningLevel=2;OutDir=bin\Debug`<br/><br/>See [Common MSBuild project properties](./common-msbuild-project-properties.md) for a list of commonly used properties. The full set of available properties depends on the project type, SDK, and imported files.|
|`-restore`<br/><br/>`-r`|Runs the `Restore` target prior to building the actual targets.|
|`-restoreProperty:{name}={value}`<br/><br/>`-rp:{name}={value}`|Set or override these project-level properties only during restore and don't use properties specified with the `-property` argument. `name` is the property name, and `value` is the property value. Use a semicolon or a comma to separate multiple properties, or specify each property separately.|
|`-target:{targets}`<br/><br/>`-t:{targets}`|Build the specified targets in the project. Specify each target separately, or use a semicolon or comma to separate multiple targets, as the following example shows:<br /><br /> `-target:PrepareResources;Compile`<br /><br /> If you specify any targets by using this switch, they're run instead of any targets in the `DefaultTargets` attribute in the project file. For more information, see [Target build order](../msbuild/target-build-order.md) and [How to: Specify which target to build first](../msbuild/how-to-specify-which-target-to-build-first.md).<br /><br /> A target is a group of tasks. For more information, see [Targets](../msbuild/msbuild-targets.md).|
|`-targets[:{file}]`<br/><br/>`-ts[:{file}]`|Write the list of available targets to the specified file (or the output device, if no file is specified), without actually executing the build process.|
|`-toolsVersion:{version}`<br/><br/>`-tv:{version}`| Specifies a custom toolset. A toolset consists of tasks, targets, and tools that are used to build an application. See [Toolset (ToolsVersion)](../msbuild/msbuild-toolset-toolsversion.md) and [Standard and custom toolset configurations](./standard-and-custom-toolset-configurations.md).|
|`-validate:[{schema}]`<br/><br/>`-val[{schema}]`|Validate the project file and, if validation succeeds, build the project.<br /><br /> If you don't specify `schema`, the project is validated against the default schema.<br /><br /> If you specify `schema`, the project is validated against the schema that you specify.<br /><br /> The following setting is an example: `-validate:MyExtendedBuildSchema.xsd`|
|`-verbosity:{level}`<br/><br/>`-v:{level}`|Specifies the amount of information to display in the build log. Each logger displays events based on the verbosity level that you set for that logger.<br /><br /> You can specify the following verbosity levels: `q[uiet]`, `m[inimal]`, `n[ormal]` (default), `d[etailed]`, and `diag[nostic]`.<br /><br /> The following setting is an example: `-verbosity:quiet`|
|`-version`<br/><br/>`-ver`|Display version information only. The project isn't built.|
|`@{file}`|Insert command-line switches from a text file. If you have multiple files, you specify them separately. For more information, see [Response files](../msbuild/msbuild-response-files.md).|
|`-warnAsError[:{code; ...}]`<br/><br/>`-err[:{code; ...}]`|List of warning codes to treats as errors. Use a semicolon or a comma to separate multiple warning codes. To treat all warnings as errors, use the switch with no values. When a warning is treated as an error, the target continues to execute as if it was a warning, but the overall build fails.<br/><br/>Example: `-err:MSB4130`|
|`-warnNotAsError[:{code; ...}]`<br/><br/>`-noerr[:{code; ...}]`|MSBuild 17.0 and later. List of warning codes that shouldn't be promoted to errors. Specifically, if the warnAsError switch is set to promote all warnings to errors, error codes specified with warnNotAsError aren't promoted. This has no effect if warnAsError isn't set to promote all warnings to errors. Use a semicolon or a comma to separate multiple warning codes. <br/><br/>Example: `-noerr:MSB4130`|
|`-warnAsMessage[:{code}; ...}]`<br/><br/>`-noWarn[:{code; ...}]`|List of warning codes to treats as low importance messages. Use a semicolon or a comma to separate multiple warning codes.<br/><br/>Example: `-noWarn:MSB3026`|

:::moniker-end

:::moniker range="visualstudio"

|Switch|Description|
|------------|-----------------|
|`-detailedSummary[:{True or False}]`<br/><br/>`-ds[:{True or False}]`|If `True`, show detailed information at the end of the build log about the configurations that were built and how they were scheduled to nodes.|
Expand All @@ -54,6 +94,7 @@ Square brackets `[]` indicate optional parts, and curly braces `{}`indicate user
|`-isolateProjects[:{True, MessageUponIsolationViolation, False}]`<br/><br/>`-isolate[:{True, MessageUponIsolationViolation, False}]`|Causes MSBuild to build each project in isolation. When set to `MessageUponIsolationViolation` (or its short form `Message`), only the results from top-level targets are serialized if the `-outputResultsCache` switch is supplied. This option is to mitigate the chances of an isolation-violating target on a dependency project using incorrect state due to its dependency on a cached target whose side effects wouldn't be taken into account. (For example, the definition of a property.) This mode is more restrictive, as it requires that the project graph be statically discoverable at evaluation time, but can improve scheduling and reduce memory overhead when building a large set of projects.|
|`-lowPriority[:{True or False}]`<br/><br/>`-low[:{True or False}]`|Causes MSBuild to run at low process priority. Specifying `-lowPriority` is the same as specifying `-lowPriority:True`.|
|`-maxCpuCount[:{number}]`<br/><br/>`-m[:{number}]`|Specifies the maximum number of concurrent processes to use when building. If you don't include this switch, the default value is 1. If you include this switch without specifying a value, MSBuild uses up to the number of processors in the computer. For more information, see [Building multiple projects in parallel](../msbuild/building-multiple-projects-in-parallel-with-msbuild.md).<br /><br /> The following example instructs MSBuild to build using three MSBuild processes, which allows three projects to build at the same time:<br /><br /> `msbuild myproject.proj -maxcpucount:3`|
|`-multiThreaded[:{True or False}]`<br/><br/>`-mt[:{True or False}]`|Enables multithreaded task execution within a single MSBuild process. When enabled, tasks that implement `IMultiThreadableTask` or have the `[MSBuildMultiThreadableTask]` attribute run in-process on multiple threads instead of in separate worker processes. Tasks that haven't opted in to multithreaded execution automatically fall back to running in a sidecar TaskHost process. Specifying `-mt` is the same as specifying `-mt:True`. Requires MSBuild 18.4 or later. For more information, see [Update a task for multithreaded builds](update-task-multithreaded.md).|
|`-noAutoResponse`<br/><br/>`-noautorsp`|Don't include any *MSBuild.rsp* or *Directory.Build.rsp* files automatically.|
|`-nodeReuse:{value}`<br/><br/>`-nr:{value}`|Enable or disable the reuse of MSBuild nodes. You can specify the following values:<br /><br /> - **True**. Nodes remain after the build finishes so that subsequent builds can use them (default).<br />- **False**. Nodes don't remain after the build completes.<br /><br /> A node corresponds to a project that's executing. If you include the `-maxcpucount` switch, multiple nodes can execute concurrently.|
|`-nologo`|Don't display the startup banner or the copyright message.|
Expand All @@ -74,6 +115,8 @@ Square brackets `[]` indicate optional parts, and curly braces `{}`indicate user
|`-warnNotAsError[:{code; ...}]`<br/><br/>`-noerr[:{code; ...}]`|MSBuild 17.0 and later. List of warning codes that shouldn't be promoted to errors. Specifically, if the warnAsError switch is set to promote all warnings to errors, error codes specified with warnNotAsError aren't promoted. This has no effect if warnAsError isn't set to promote all warnings to errors. Use a semicolon or a comma to separate multiple warning codes. <br/><br/>Example: `-noerr:MSB4130`|
|`-warnAsMessage[:{code}; ...}]`<br/><br/>`-noWarn[:{code; ...}]`|List of warning codes to treats as low importance messages. Use a semicolon or a comma to separate multiple warning codes.<br/><br/>Example: `-noWarn:MSB3026`|

:::moniker-end

## Switches for loggers

|Switch|Description|
Expand Down
2 changes: 2 additions & 0 deletions docs/msbuild/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ items:
href: msbuild-tasks.md
- name: Task writing
href: task-writing.md
- name: Update a task for multithreaded builds
href: update-task-multithreaded.md
- name: Formats for errors and warnings
href: msbuild-diagnostic-format-for-tasks.md
- name: Ignore errors in tasks
Expand Down
Loading