Support artifacts output mode for MTP test results - #55609
Merged
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
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) integration to recognize MSBuild’s artifacts output mode and default test results into the artifacts layout when enabled, while preserving explicitly specified --results-directory / --results-directory-layout behavior. It also ensures artifact post-processing outputs land in the shared artifacts results directory.
Changes:
- Plumb
UseArtifactsOutput,ArtifactsPath,ArtifactsProjectName, andArtifactsPivotsfrom evaluated test projects into the MTPTestModulemodel. - Update results-directory resolution to default to
<ArtifactsPath>/test-results/<project>/<pivot>when artifacts output is enabled (unless the user explicitly overrides results directory/layout). - Adjust artifact post-processing output directory selection and expand test coverage for artifacts output defaults and precedence rules.
Show a summary per file
| File | Description |
|---|---|
| test/dotnet.Tests/CommandTests/Test/TestResultsDirectoryResolverTests.cs | Adds unit tests covering artifacts output defaults and explicit layout precedence. |
| test/dotnet.Tests/CommandTests/Test/TestCommandParserTests.cs | Extends parser tests to validate the new ResultsDirectoryLayoutSpecified signal. |
| test/dotnet.Tests/CommandTests/Test/GivenDotnetTestBuildsAndRunsTests.cs | Adds an integration test verifying artifacts output places reports under artifacts/test-results and avoids TestResults. |
| test/dotnet.Tests/CommandTests/Test/ArtifactPostProcessingManagerTests.cs | Adds coverage for artifact-mode output directory selection; refactors job construction for module injection. |
| src/Cli/dotnet/Commands/Test/MTP/TestResultsDirectoryResolver.cs | Implements artifacts-aware default root/layout behavior and introduces ResultsDirectoryLayoutSpecified-gated defaults. |
| src/Cli/dotnet/Commands/Test/MTP/SolutionAndProjectUtility.cs | Reads artifacts-related MSBuild properties and stores them into TestModule. |
| src/Cli/dotnet/Commands/Test/MTP/Options.cs | Adds ResultsDirectoryLayoutSpecified to PathOptions. |
| src/Cli/dotnet/Commands/Test/MTP/MSBuildUtility.cs | Sets ResultsDirectoryLayoutSpecified based on whether --results-directory-layout was explicitly provided. |
| src/Cli/dotnet/Commands/Test/MTP/Models.cs | Extends TestModule to carry artifacts output metadata. |
| src/Cli/dotnet/Commands/Test/MTP/ArtifactPostProcessingManager.cs | Prefers the artifacts results directory as the merge output location when artifacts output is enabled. |
| src/Cli/dotnet/Commands/Test/CliConstants.cs | Adds MSBuild property name constants for artifacts output mode integration. |
Copilot's findings
Suppressed comments (1)
src/Cli/dotnet/Commands/Test/MTP/TestResultsDirectoryResolver.cs:236
- This comment claims the pivot deliberately excludes configuration, but when artifacts output defaults are used the pivot comes from $(ArtifactsPivots), whose default value includes configuration (for example: debug_net8.0). This mismatch makes the behavior harder to reason about and can confuse future changes.
/// The pivot folder distinguishing runs of the same project across target frameworks and
/// runtimes. Multiple elements are joined by an underscore, following the artifacts layout.
/// The configuration is deliberately not part of the pivot: a single test run targets one
/// configuration, so it would only ever add a constant level to every path.
/// </summary>
- Files reviewed: 11/11 changed files
- Comments generated: 1
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 006e6be5-b01a-46e4-ab59-ea54c91a2864
Evangelink
enabled auto-merge
August 6, 2026 07:59
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 006e6be5-b01a-46e4-ab59-ea54c91a2864
Member
Author
|
@baronfel FYI |
YuliiaKovalova
approved these changes
Aug 7, 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
UseArtifactsOutput,ArtifactsPath,ArtifactsProjectName, andArtifactsPivotsfrom evaluated MTP test projects<ArtifactsPath>/test/<project>/<pivot>when artifacts output is enabled--results-directoryand--results-directory-layoutchoicesThe
testcategory is a sibling ofbin,obj,package, andpublish; it can contain reports, coverage, diagnostics, and other generated test artifacts without implying every file is a test result.Fixes #54612
Validation
build.cmddotnet.Testscovering artifacts defaults, explicit layout precedence, collisions, and artifact post-processing