Repository navigation
[release/11.0.1xx] Forward MSBuild -mt switches to the build engine - #56207
Merged
JanProvaznik merged 2 commits intoSep 10, 2026
Merged
JanProvaznik merged 2 commits into
JanProvaznik merged 2 commits into
Conversation
… argument (dotnet#56120) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> (cherry picked from commit 6d10cf8)
JanProvaznik
requested review from
a team,
lbussell,
mthalman and
tmat
as code owners
September 9, 2026 16:00
|
Azure Pipelines: Successfully started running 2 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
It changes core CLI build/forwarding behavior (run/test/watch) and introduces a new MSBuild command-line assembly reference path, which warrants final human validation for servicing-branch safety.
Pull request overview
Backports the fix to ensure MSBuild build-engine -mt/-multithreaded switches are treated as MSBuild-only and forwarded to the underlying build invocation (instead of leaking to launched applications), including correct handling across -- boundaries and dotnet-watch file discovery.
Changes:
- Extend MSBuild-only token separation (previously logger-focused) to also recognize
-mt/-multithreadedand route these to MSBuild fordotnet runanddotnet test(MTP). - Update dotnet-watch argument handling to exclude MSBuild-only switches from positional file discovery while still forwarding them to the internal
dotnet buildinvocation. - Factor the MSBuild command-line assembly reference logic into
MSBuildRuntimeReference.targetsand import it where needed; add regression coverage for quoting/response-file/--cases.
File summaries
| File | Description |
|---|---|
| test/dotnet.Tests/LoggerUtilityTests.cs | Adds coverage for recognizing -mt forms as MSBuild-only and preserves -- semantics for MTP. |
| test/dotnet.Tests/CommandTests/Run/RunParserTests.cs | Validates dotnet run keeps -mt on the MSBuild side before -- and treats it as app args after --. |
| test/dotnet.Tests/CommandTests/Run/RunFileTests_BuildOptions.cs | Adds end-to-end coverage for response files, env vars, and node-count behavior when -mt is used. |
| test/dotnet-watch.Tests/CommandLine/ProgramTests.GetProjectOptions.cs | Ensures file-based entry point discovery isn’t broken when -mt precedes the file argument. |
| test/dotnet-watch.Tests/CommandLine/CommandLineOptionsTests.cs | Adds watch forwarding/file-discovery coverage for -mt valid/invalid and -- boundary cases. |
| src/Dotnet.Watch/dotnet-watch/Program.cs | Switches file discovery parsing to use the new filtered argument list. |
| src/Dotnet.Watch/dotnet-watch/CommandLine/CommandLineOptions.cs | Filters MSBuild-only tokens (binlog + -mt) out of file-discovery args and forwards -mt to build args. |
| src/Cli/MSBuildRuntimeReference.targets | New shared target/import providing MSBuild command-line assembly reference + package path validation. |
| src/Cli/Microsoft.DotNet.Cli.Utils/Microsoft.DotNet.Cli.Utils.csproj | Replaces inlined MSBuild runtime reference logic with shared import. |
| src/Cli/Microsoft.DotNet.Cli.Definitions/Utilities/MSBuildArgumentParser.cs | Adds centralized parsing for recognizing valid -mt/-multithreaded switch forms (incl. MSBuild-style quoting). |
| src/Cli/dotnet/LoggerUtility.cs | Generalizes logger-only splitting into “MSBuild-only” splitting and includes -mt recognition. |
| src/Cli/dotnet/dotnet.csproj | Imports shared MSBuild runtime reference targets so dotnet can use MSBuild command-line internals. |
| src/Cli/dotnet/Commands/Test/MTP/MSBuildUtility.cs | Routes MSBuild-only tokens (incl. -mt) to MSBuild while preserving args after -- for the test app. |
| src/Cli/dotnet/Commands/Run/VirtualProjectBuildingCommand.cs | Applies MSBuild -mt/node-count to in-process build parameters (managed-only). |
| src/Cli/dotnet/Commands/Run/RunCommand.cs | Ensures MSBuild-only tokens don’t leak into application args for dotnet run. |
| src/Cli/dotnet/Commands/Publish/PublishCommand.cs | Renames transformer arg to reflect generalized MSBuild-only splitting. |
| src/Cli/dotnet/Commands/Pack/PackCommand.cs | Renames transformer arg to reflect generalized MSBuild-only splitting. |
| src/Cli/dotnet/Commands/DotNetCommandFactory.cs | Uses generalized MSBuild-only splitting so -mt doesn’t interfere with file-based program routing. |
| src/Cli/AGENTS.md | Documents the shared MSBuild command-line assembly reference mechanism and constraints. |
Review details
- Files reviewed: 19/19 changed files
- Comments generated: 0
- Review effort level: Lite
Evangelink
approved these changes
Sep 9, 2026
JanProvaznik
enabled auto-merge (squash)
September 10, 2026 08:46
JanProvaznik
disabled auto-merge
September 10, 2026 08:46
Member
Author
|
checked offline that rc2 is not locked down, so removing the auto-applied servicing label |
JanProvaznik
had a problem deploying
to
copilot-pat-pool
September 10, 2026 11:25 — with
GitHub Actions
Failure
4 of 14 tasks
3 of 7 tasks
karolz-ms
added a commit
to microsoft/aspire
that referenced
this pull request
Sep 24, 2026
## Description Project Resource V2 makes the dashboard available earlier, but coordinated project builds can delay full application readiness. .NET SDK 11 RC1 introduces the `-mt` MSBuild switch, which allows supported project builds to use multithreaded task execution. This change: - Detects the `dotnet` SDK selected for each build context, including `global.json` selection and prerelease versions. - Enables `-mt` for coordinated traversal builds and project rebuild commands when the selected SDK supports the target: - Project and generated traversal builds use `11.0.100-rc.1` or newer. - File-based `.cs` builds use `11.0.100-rtm.26473.104` or newer; stable `11.0.100` and later are included. - Uses the stricter file-based build floor because earlier .NET 11 prereleases lack both safe `-mt` argument forwarding and the compiler-client mutex mitigation. The required fixes landed in dotnet/sdk#56207, dotnet/roslyn#85675, and dotnet/dotnet#9565. - Caches version probes by SDK-selection context and refreshes the result when `global.json` changes. - Reuses the same provider for existing file-based app and .NET tool SDK validation. - Omits `-mt` when version detection fails, preserving the existing build behavior. Validation: - `.\restore.cmd` - `./restore.sh` - Affected `Aspire.Hosting` and `Aspire.Hosting.Dotnet` build completed with zero warnings and errors. - 47 focused provider, version-policy, coordinated-build, rebuild, file-app, and .NET-tool tests passed. - 15 focused `Aspire.Hosting.Tests` file-app SDK policy and environment-aware provider cases passed. - 6 focused `Aspire.Hosting.Dotnet.Tests` file-only build, rebuild, mixed-model coordination, and configured rebuild argument cases passed. - A repository-local .NET 11 RC1 `.csproj` build completed successfully with `-mt`. - A full `Aspire.Hosting.Tests` run encountered two unrelated `MSBuildTests` timeouts in `dotnet build --disable-build-servers`; both timeouts reproduced when retried in isolation. Fixes #19944 ## Checklist - Is this feature complete? - [x] Yes. Ready to ship. - [ ] No. Follow-up changes expected. - Are you including unit tests for the changes and scenario tests if relevant? - [x] Yes - [ ] No - Did you add public API? - [ ] Yes - If yes, did you have an API Review for it? - [ ] Yes - [ ] No - Did you add `<remarks />` and `<code />` elements on your triple slash comments? - [ ] Yes - [ ] No - [x] No - Does the change make any security assumptions or guarantees? - [ ] Yes - If yes, have you done a threat model and had a security review? - [ ] Yes - [ ] No - [x] No --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This branch had an error being deployed
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.
Backport of #56120 to
release/11.0.1xx.Cherry-picked the squash commit
6d10cf8ab0e932ec2efa5c74eb759ec75d06ae9c. This branch contains one commit on top of the release branch, without unrelatedmainhistory.Release-specific adaptations
MSBuildUtility, where that logic lives on the release branch, rather than adding main's extractedTestCommandOptionsclass. Preserve arguments after--and add coverage for that boundary.-mtregression uses--verbose; the unrelated main-only--tracefeature is not backported.Validation