Repository navigation
Honor MSBuild -mt in MTP test preparation - #56893
Merged
Merged
Conversation
Preserve strict MT working-directory ownership and isolate interleaved build/restore operations while retaining the shared preparation binlog. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Evangelink
requested review from
a team,
lbussell and
mthalman
as code owners
November 2, 2026 10:03
|
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.
🟢 Approval recommended
No active review issues block approval of the MTP preparation changes.
No open issues 🎉
What changed in this PR
This PR makes Microsoft.Testing.Platform (MTP) preparation honor MSBuild’s explicit -mt settings and environment precedence, including --no-build, while preserving the shared preparation session and binlog.
Changes:
- Applies multithreading settings to preparation without adding automatic response-file discovery.
- Preserves strict-mode working-directory ownership by running intervening builds and restores out-of-process at the captured invocation directory.
- Adds regression coverage for switch precedence, device operations, file-based apps, failures, and binlogs, and documents the session invariant.
| File | Description |
|---|---|
test/dotnet.Tests/CommandTests/Test/GivenDotnetTestSelectsDevice.cs |
Covers deployment and run-argument failures with MT enabled and disabled. |
test/dotnet.Tests/CommandTests/Test/GivenDotnetTestRunsFileBasedApps.cs |
Verifies MT preparation for file-based --no-build runs. |
test/dotnet.Tests/CommandTests/Test/GivenDotnetTestProducesBinaryLog.cs |
Tests switch precedence, preparation execution mode, failures, and coherent binlogs. |
src/Cli/Microsoft.DotNet.Cli.Utils/MSBuildForwardingAppWithoutLogging.cs |
Supports out-of-process execution in a specified working directory. |
src/Cli/dotnet/MSBuildSession.cs |
Applies MT settings and preserves strict-mode directory ownership. |
src/Cli/dotnet/Commands/Test/MTP/MSBuildUtility.cs |
Resolves input paths and routes intervening builds through session-aware execution. |
src/Cli/dotnet/Commands/Restore/RestoringCommand.cs |
Propagates out-of-process execution to separate restore and main build operations. |
src/Cli/dotnet/Commands/MSBuild/MSBuildForwardingApp.cs |
Exposes working-directory-aware out-of-process forwarding. |
src/Cli/AGENTS.md |
Documents MTP preparation lifecycle and regression requirements. |
Review effort: Balanced
JanProvaznik
approved these changes
Nov 2, 2026
JanProvaznik
left a comment
Member
There was a problem hiding this comment.
overall reasonable
should we get this also for release/11.0.2xx branch ?
Member
Author
|
/backport to release/11.0.1xx |
Contributor
|
Started backporting to |
Contributor
|
@Evangelink backporting to git am output$ git cherry-pick 2f0da079350a63d165b990e0cbfb3ead6bd09a58
Auto-merging src/Cli/AGENTS.md
CONFLICT (content): Merge conflict in src/Cli/AGENTS.md
Auto-merging src/Cli/Microsoft.DotNet.Cli.Utils/MSBuildForwardingAppWithoutLogging.cs
CONFLICT (content): Merge conflict in src/Cli/Microsoft.DotNet.Cli.Utils/MSBuildForwardingAppWithoutLogging.cs
Auto-merging src/Cli/dotnet/Commands/MSBuild/MSBuildForwardingApp.cs
Auto-merging src/Cli/dotnet/Commands/Restore/RestoringCommand.cs
Auto-merging src/Cli/dotnet/Commands/Test/MTP/MSBuildUtility.cs
CONFLICT (content): Merge conflict in src/Cli/dotnet/Commands/Test/MTP/MSBuildUtility.cs
Auto-merging src/Cli/dotnet/MSBuildSession.cs
Auto-merging test/dotnet.Tests/CommandTests/Test/GivenDotnetTestProducesBinaryLog.cs
CONFLICT (modify/delete): test/dotnet.Tests/CommandTests/Test/GivenDotnetTestRunsFileBasedApps.cs deleted in HEAD and modified in 2f0da07935 (Honor MSBuild -mt in MTP test preparation (#56893)). Version 2f0da07935 (Honor MSBuild -mt in MTP test preparation (#56893)) of test/dotnet.Tests/CommandTests/Test/GivenDotnetTestRunsFileBasedApps.cs left in tree.
Auto-merging test/dotnet.Tests/CommandTests/Test/GivenDotnetTestSelectsDevice.cs
error: could not apply 2f0da07935... Honor MSBuild -mt in MTP test preparation (#56893)
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch
Applying: Honor MSBuild -mt in MTP test preparation
Using index info to reconstruct a base tree...
M src/Cli/AGENTS.md
M src/Cli/Microsoft.DotNet.Cli.Utils/MSBuildForwardingAppWithoutLogging.cs
M src/Cli/dotnet/Commands/MSBuild/MSBuildForwardingApp.cs
M src/Cli/dotnet/Commands/Restore/RestoringCommand.cs
M src/Cli/dotnet/Commands/Test/MTP/MSBuildUtility.cs
M src/Cli/dotnet/MSBuildSession.cs
M test/dotnet.Tests/CommandTests/Test/GivenDotnetTestProducesBinaryLog.cs
A test/dotnet.Tests/CommandTests/Test/GivenDotnetTestRunsFileBasedApps.cs
M test/dotnet.Tests/CommandTests/Test/GivenDotnetTestSelectsDevice.cs
Falling back to patching base and 3-way merge...
Auto-merging src/Cli/AGENTS.md
CONFLICT (content): Merge conflict in src/Cli/AGENTS.md
Auto-merging src/Cli/Microsoft.DotNet.Cli.Utils/MSBuildForwardingAppWithoutLogging.cs
CONFLICT (content): Merge conflict in src/Cli/Microsoft.DotNet.Cli.Utils/MSBuildForwardingAppWithoutLogging.cs
Auto-merging src/Cli/dotnet/Commands/MSBuild/MSBuildForwardingApp.cs
Auto-merging src/Cli/dotnet/Commands/Restore/RestoringCommand.cs
Auto-merging src/Cli/dotnet/Commands/Test/MTP/MSBuildUtility.cs
CONFLICT (content): Merge conflict in src/Cli/dotnet/Commands/Test/MTP/MSBuildUtility.cs
Auto-merging src/Cli/dotnet/MSBuildSession.cs
Auto-merging test/dotnet.Tests/CommandTests/Test/GivenDotnetTestProducesBinaryLog.cs
CONFLICT (modify/delete): test/dotnet.Tests/CommandTests/Test/GivenDotnetTestRunsFileBasedApps.cs deleted in HEAD and modified in Honor MSBuild -mt in MTP test preparation. Version Honor MSBuild -mt in MTP test preparation of test/dotnet.Tests/CommandTests/Test/GivenDotnetTestRunsFileBasedApps.cs left in tree.
Auto-merging test/dotnet.Tests/CommandTests/Test/GivenDotnetTestSelectsDevice.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 Honor MSBuild -mt in MTP test preparation
Error: The process '/usr/bin/git' failed with exit code 128 |
This was referenced Nov 3, 2026
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.
Related to #56837.
MTP has the same preparation gap:
dotnet test -mtforwards the switch to its main build, but the sharedMSBuildSessionnever applies it toBuildParameters. Restore, device discovery, deployment, andComputeRunArgumentstherefore ignore explicit MT settings, including--no-buildpreparation.Apply recognized explicit switches using MSBuild's existing parser and environment precedence. Preserve the single-node limit, target-produced project state, and one coherent preparation binlog; do not add response-file discovery or depend on the unmerged run-command PR.
A flag-only fix is insufficient for MTP's long-lived session. The bundled engine's strict-mode scope owns the process current directory until
EndBuildand permits only one active strict build per process. Restoring CWD between requests causes MSB4286; interleaving another in-process build causes MSB4289. Keep MT's CWD ownership intact and run intervening build/restore operations out-of-process at the captured invocation directory. Existing execution policy is unchanged when no MT preparation session is active, and relative arguments/log paths keep their original meaning.Add real-product regressions for aliases, quoted/empty values, duplicate precedence, environment overrides, per-target execution mode, relative project paths, device listing, file-based
--no-build, multi-project/multi-TFM binlogs, and restore/build/deployment/run-argument failures. Update CLI contributor guidance with the session invariant.Validation
Windows x64, built SDK
12.0.100-dev, bootstrap SDK12.0.100-alpha.1.26480.102, bundled Microsoft.Build18.13.0-1.26528.111, and MTP2.6.0-preview.26531.5. No dependency versions changed.dotnet.Tests: 169 passed, 0 failed, 0 skipped. These execute the assembled SDK and assert actual target working directories, module results, exit codes, log placement, and binlog structure.Microsoft.DotNet.Cli.Utils.Tests: 236 passed, 0 failed, 7 existing platform/issue skips.dotnet-aot.csprojmanaged/shared-source compilation passed without warnings.Commands used for the final validation:
All commands above exited 0. TRX and build binlogs are retained under
artifacts\log\test-runs\dotnet.Tests\20261102-093421-154276andartifacts\log\test-runs\Microsoft.DotNet.Cli.Utils.Tests\20261102-095013-255352.