Repository navigation
Fix MT switch - #14682
Merged
Merged
Fix MT switch#14682
Conversation
Support /mt, /mt:true, and /mt:false with latest-value precedence and command-line override of MSBUILDFORCEMULTITHREADED. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5015a21e-6f89-4a48-9467-bd3c9d196294
Add MSBUILDENABLEMULTITHREADED while keeping MSBUILDFORCEMULTITHREADED authoritative. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5015a21e-6f89-4a48-9467-bd3c9d196294
Contributor
There was a problem hiding this comment.
Pull request overview
Updates MSBuild’s experimental multi-threaded mode switch (-multiThreaded / -mt) to behave like a real boolean switch (including response-file precedence), and splits environment configuration into “force” vs “soft default” knobs to enable a future default-on story without removing opt-out.
Changes:
- Make
-mt/-multithreadedsupport:true|false(including last-one-wins semantics and correct response-file vs command-line precedence). - Add
MSBUILDENABLEMULTITHREADED=1as a soft default while keepingMSBUILDFORCEMULTITHREADED=1authoritative. - Add resources + unit tests + documentation updates for the new parsing/precedence behavior.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/MSBuild/XMake.cs | Implements precedence logic (force env var → last -mt value → enable env var → off) and adds invalid-value handling via ProcessBooleanSwitch. |
| src/MSBuild/CommandLine/CommandLineParser.cs | Treats -mt/-multithreaded as having an optional parameter by defaulting missing values to :true. |
| src/MSBuild.UnitTests/XMake_Tests.cs | Adds unit tests for boolean parsing, last-one-wins behavior, env-var precedence, and invalid-value rejection. |
| src/Framework/Traits.cs | Introduces EnableMultiThreaded trait backed by MSBUILDENABLEMULTITHREADED. |
| src/MSBuild/Resources/Strings.resx | Updates help text to show `-multithreaded[:true |
| src/MSBuild/Resources/xlf/Strings.cs.xlf | Localized help/source update and adds InvalidMultiThreadedValue trans-unit. |
| src/MSBuild/Resources/xlf/Strings.de.xlf | Localized help/source update and adds InvalidMultiThreadedValue trans-unit. |
| src/MSBuild/Resources/xlf/Strings.es.xlf | Localized help/source update and adds InvalidMultiThreadedValue trans-unit. |
| src/MSBuild/Resources/xlf/Strings.fr.xlf | Localized help/source update and adds InvalidMultiThreadedValue trans-unit. |
| src/MSBuild/Resources/xlf/Strings.it.xlf | Localized help/source update and adds InvalidMultiThreadedValue trans-unit. |
| src/MSBuild/Resources/xlf/Strings.ja.xlf | Localized help/source update and adds InvalidMultiThreadedValue trans-unit. |
| src/MSBuild/Resources/xlf/Strings.ko.xlf | Localized help/source update and adds InvalidMultiThreadedValue trans-unit. |
| src/MSBuild/Resources/xlf/Strings.pl.xlf | Localized help/source update and adds InvalidMultiThreadedValue trans-unit. |
| src/MSBuild/Resources/xlf/Strings.pt-BR.xlf | Localized help/source update and adds InvalidMultiThreadedValue trans-unit. |
| src/MSBuild/Resources/xlf/Strings.ru.xlf | Localized help/source update and adds InvalidMultiThreadedValue trans-unit. |
| src/MSBuild/Resources/xlf/Strings.tr.xlf | Localized help/source update and adds InvalidMultiThreadedValue trans-unit. |
| src/MSBuild/Resources/xlf/Strings.zh-Hans.xlf | Localized help/source update and adds InvalidMultiThreadedValue trans-unit. |
| src/MSBuild/Resources/xlf/Strings.zh-Hant.xlf | Localized help/source update and adds InvalidMultiThreadedValue trans-unit. |
| documentation/wiki/MSBuild-Environment-Variables.md | Documents the split between force (MSBUILDFORCEMULTITHREADED) and soft default (MSBUILDENABLEMULTITHREADED). |
| documentation/specs/multithreading/multithreaded-msbuild.md | Updates the multithreading spec to reflect new switch + env-var semantics and precedence. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
rainersigwald
approved these changes
Aug 11, 2026
Co-authored-by: Rainer Sigwald <raines@microsoft.com>
JanProvaznik
enabled auto-merge (squash)
August 12, 2026 07:53
JanProvaznik
approved these changes
Aug 12, 2026
AlesProkop
approved these changes
Aug 12, 2026
Member
Author
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
This was referenced Oct 16, 2026
Closed
This was referenced Oct 18, 2026
Closed
Merged
Merged
Closed
Merged
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Context
-multiThreaded/-mtwas a presence-only switch: any occurrence turned multi-threaded mode on, and there was no way to turn it back off. That blocks turning MT on by default later, because users would have no opt-out — including anyone who inherits-mtfrom an auto-response file or a repo'sDirectory.Build.rsp. It also meant-mt:falsesilently enabled MT, the opposite of what it reads like.MSBUILDFORCEMULTITHREADED=1 was the only environment opt-in, and it was documented as "equivalent to passing -mt ". Once the switch can express false , "equivalent to -mt " and "force" are two different things and need two different knobs.
Changes Made
-mtis now a real boolean switch:-mtand-mt:trueenable;-mt:falsedisables. Repeated occurrences take the last value, matching-nodeReuseand-m. This holds across response files as well: the command line beats the auto-response file andDirectory.Build.rsp.Now we have two environment variables with distinct meanings
MSBUILDFORCEMULTITHREADED=1 is Authoritative — forces MT on
MSBUILDENABLEMULTITHREADED=1 is Soft default — MT on unless told otherwise
Resulting precedence: force env var → last -mt value → enable env var → off.
Testing
New unit tests