Use partial evaluation in dotnet test setup - #55633
Merged
Merged
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: e05d5996-f5a3-444d-bd9c-1bd2a661b3ef
|
Azure Pipelines: Successfully started running 1 pipeline(s). 2 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.
Pull request overview
This PR updates dotnet test’s Microsoft.Testing.Platform (MTP) project discovery to use MSBuild partial evaluation (stopping after Properties/Items where possible) to reduce discovery-time evaluation work while preserving correctness where full evaluation is required.
Changes:
- Introduces
ProjectEvaluationStage-based partial evaluation in MTP discovery, with full evaluation reserved for MTP applications that need target execution. - Uses partial evaluation when inspecting capabilities/items during build/restore and when selecting a target framework for device scenarios.
- Adds a regression test asset + test to validate post-build discovery observes newly generated imports (fresh evaluation context after build).
Show a summary per file
| File | Description |
|---|---|
| test/TestAssets/TestProjects/DotnetTestDevices/DotnetTestDevices.csproj | Adds a conditional post-build props import and a build-time generator target for the regression scenario. |
| test/dotnet.Tests/CommandTests/Test/GivenDotnetTestSelectsDevice.cs | Adds a test covering the fresh evaluation context boundary after build. |
| src/Cli/dotnet/Commands/Test/MTP/SolutionAndProjectUtility.cs | Switches project discovery evaluations to partial stages and re-evaluates to Full when MTP target execution is needed. |
| src/Cli/dotnet/Commands/Test/MTP/MSBuildUtility.cs | Uses Items-stage evaluation when probing runtime-environment-variable capability during build/restore. |
| src/Cli/dotnet/Commands/Test/MTP/MicrosoftTestingPlatformTestCommand.cs | Uses Properties-stage evaluation when reading TargetFramework(s) for device-driven framework selection. |
Copilot's findings
- Files reviewed: 5/5 changed files
- Comments generated: 1
Evangelink
enabled auto-merge
August 6, 2026 11:51
Member
Author
|
@ViktorHofer @baronfel I have tried to adopt the partial eval features to dotnet test, please review. |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: e05d5996-f5a3-444d-bd9c-1bd2a661b3ef
ViktorHofer
reviewed
Aug 6, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: e05d5996-f5a3-444d-bd9c-1bd2a661b3ef
ViktorHofer
approved these changes
Aug 6, 2026
drognanar
approved these changes
Aug 6, 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.
Summary
Use MSBuild partial evaluation in two
dotnet testsetup paths that consume only early evaluation results:TargetFrameworkandTargetFrameworksProjectCapabilityandIntermediateOutputPathCore project/module discovery continues to fully evaluate each project and target framework exactly once. MTP applications execute
DeployToDeviceandComputeRunArguments, so theirProjectInstancemust contain registered targets; partialProjectInstanceevaluation is not resumable and must not be followed by a second full evaluation.The existing shared
EvaluationContextremains scoped across each post-build discovery operation to reuse SDK resolution and filesystem observations between its full project evaluations.Evaluation lifetime
The pre-build device-selection evaluation and post-build discovery intentionally use different shared evaluation contexts. This prevents filesystem observations cached before the build from hiding imports or generated files created by the build.
The regression test creates a conditional props import during the build and verifies that post-build discovery observes it. It also removes the generated import before each invocation so repeated local runs continue to exercise the cache boundary.
Tests
ItUsesFreshEvaluationContextAfterBuilddotnet.Testscoverage for MTP multi-target discovery, traversal/non-test filtering, VSTest non-test handling, and device/environment target execution