Repository navigation
Preserve invocation context during MTP strict-MT preparation - #56909
Merged
Merged
Conversation
Keep background workload global.json and NuGet configuration anchored to the captured invocation directory, and initialize absolute diagnostic trace paths before strict MT owns the process directory. Preserve the existing public restoring-command constructor and add configuration and real-product trace regressions. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Evangelink
requested review from
a team,
lbussell and
mthalman
as code owners
November 3, 2026 12:52
|
Azure Pipelines: Successfully started running 1 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. |
Member
Author
|
/azp run dotnet-sdk-public-ci |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Evangelink
enabled auto-merge (squash)
November 3, 2026 13:01
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the changes preserving invocation-directory behavior during MTP preparation.
No open issues 🎉
What changed in this PR
This follow-up to #56893 preserves the invocation directory for parent-process operations during Microsoft Testing Platform (MTP) strict-MT preparation, without changing MSBuild’s directory ownership or the public RestoringCommand constructor contract.
Changes:
- Pass the captured directory through background workload updates for repository-local
global.jsonand NuGet configuration lookup. - Resolve and cache absolute trace paths before strict-MT preparation begins.
- Add workload and trace regressions, including file-based execution, and document the directory invariant.
| File | Description |
|---|---|
test/dotnet.Tests/NuGetPackageDownloaderTests.cs |
Tests captured-directory workload configuration and local-feed lookup. |
test/dotnet.Tests/CommandTests/Test/GivenDotnetTestRunsFileBasedApps.cs |
Adds trace assertions to file-based no-build coverage. |
test/dotnet.Tests/CommandTests/Test/GivenDotnetTestProducesBinaryLog.cs |
Tests relative and absolute trace paths across preparation modes. |
src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs |
Forwards a directory override through the workload downloader factory. |
src/Cli/dotnet/Commands/Workload/Install/WorkloadManifestUpdater.cs |
Uses the captured directory for workload and NuGet configuration. |
src/Cli/dotnet/Commands/Test/MTP/MSBuildUtility.cs |
Passes the session’s invocation directory to RestoringCommand. |
src/Cli/dotnet/Commands/Test/MTP/MicrosoftTestingPlatformTestCommand.cs |
Initializes trace logging before managed preparation starts. |
src/Cli/dotnet/Commands/Test/MTP/Logger.cs |
Normalizes and caches the absolute trace path. |
src/Cli/dotnet/Commands/Restore/RestoringCommand.cs |
Captures the directory before scheduling background updates. |
src/Cli/AGENTS.md |
Documents parent-process invocation-directory requirements. |
Review effort: Balanced
0101
approved these changes
Nov 3, 2026
drognanar
approved these changes
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.
Strict-MT MTP preparation owns the process current directory until its MSBuild session ends. Parent-side operations must retain the invocation directory: otherwise background workload updates can miss repository
global.jsonandNuGet.Config, and relativeDOTNET_CLI_TEST_TRACEFILEpaths can produce caught I/O exceptions andMSB4287whiledotnet testexits successfully without the requested trace.Capture the invocation directory before scheduling background updates and forward it through workload manifest discovery and the existing NuGet downloader override. Normalize and cache the trace path before managed MTP preparation starts. This preserves main's public
CommandServicesconstructor contract, file-based execution, and strict-MT directory ownership without disabling updates or weakening MSBuild checks.Follow-up to #56893. The matching release backport is #56908.
Validation
CommandServicespropagation, preparation failures, and multi-project/multi-TFM binlogs.MSB4287, and no requested trace. After the fix, strict-MT relative, strict-MT absolute, legacy relative, and disabled-logging controls all exit 0 without those errors; enabled traces contain project-loading and test-process events.dotnet.dllandMicrosoft.DotNet.Cli.Utils.dllwere explicitly deployed into the redist layout, with matching SHA-256 hashes confirmed before and after the test runner.Windows
win-x64; built SDK12.0.100-dev, runtime12.0.0-alpha.1.26528.111, MSBuild18.13.0-1.26528.111, MTP2.6.0-preview.26531.5, and MSTest4.6.0-preview.26531.5. Bootstrap SDK:12.0.100-alpha.1.26480.102.Exact commands and retained local diagnostics
All commands exited 0. Runs used a process-local bounded
PATH,DOTNET_ADD_GLOBAL_TOOLS_TO_PATH=0,MSBUILDUSESERVER=0, andMSBUILDDISABLENODEREUSE=1; user settings were not changed.Retained locally:
artifacts\log\test-runs\dotnet.Tests\20261103-112921-40944\test-results.trxandbuild.binlog.artifacts\log\Debug\mtp-cwd-main-baseline-product-results.jsonandmtp-cwd-main-fixed-product-results.json.artifacts\log\Debug\mtp-cwd-main-fixed-focused-runner.log.