Repository navigation
Fix dotnet test device discovery for multi-targeted projects - #56054
Conversation
|
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. |
There was a problem hiding this comment.
🔵 Needs a closer look
Pull request overview
This PR updates the dotnet test device-selection pipeline for Microsoft.Testing.Platform projects so that device discovery works for multi-targeted (TargetFrameworks) projects where workload/device targets are only imported in TFM-specific inner builds (i.e., after TargetFramework is set). It also extends the existing DotnetTestDevices test asset and adds new integration coverage to prevent regressions.
Changes:
- Update device discovery to enumerate TFMs from the outer evaluation, then probe each TFM-specific inner evaluation for
ComputeAvailableDevicesbefore running device selection. - Track whether device-selection restore was performed and use it to suppress redundant restore in subsequent per-TFM builds when applicable.
- Refactor the
DotnetTestDevicestest asset to conditionally importComputeAvailableDevicesonly in inner builds, and add newdotnet.Testscoverage for the multi-targeting scenarios.
File summaries
| File | Description |
|---|---|
| test/TestAssets/TestProjects/DotnetTestDevices/DotnetTestDevices.Device.targets | New targets file providing ComputeAvailableDevices for the test asset. |
| test/TestAssets/TestProjects/DotnetTestDevices/DotnetTestDevices.csproj | Import device targets only when TargetFramework is set (inner-build behavior). |
| test/dotnet.Tests/CommandTests/Test/GivenDotnetTestSelectsDevice.cs | Add integration tests validating device discovery in cross-targeting outer evaluations and mixed-TFM support. |
| test/dotnet.Tests/CommandTests/Test/GivenDotnetTestProducesBinaryLog.cs | Ensure solution/binlog scenarios copy the extracted device targets file as part of test setup. |
| src/Cli/dotnet/Commands/Test/MTP/SolutionAndProjectUtility.cs | Probe per-TFM evaluations for ComputeAvailableDevices; track restore-performed status through device selection result. |
| src/Cli/dotnet/Commands/Test/MTP/MSBuildUtility.cs | Use the new restore-performed signal to avoid redundant restore in per-TFM builds when no RID-specific restore is needed. |
Review details
- Files reviewed: 6/6 changed files
- Comments generated: 0
- Review effort level: Lite
Evangelink
left a comment
There was a problem hiding this comment.
Found two issues: one correctness gap in solution-specific project property handling and one large-solution performance regression.
Note
This review was generated with AI assistance.
743b38b to
51c7a62
Compare
Evangelink
left a comment
There was a problem hiding this comment.
Two issues remain: a cross-platform regression test failure and an unresolved large-solution evaluation performance regression.
Probe ComputeAvailableDevices per target framework so workload targets imported only by inner builds participate in device selection. Reuse the device-selection restore across target frameworks and cover mixed device projects. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 044214d8-b337-4b2c-b368-975cf2ea166d
51c7a62 to
3c8cdb3
Compare
Evangelink
left a comment
There was a problem hiding this comment.
Re-reviewed the updated head. The cross-platform solution-mapping test failure is addressed, but the large-solution performance concern remains: inner-TFM evaluation for every project is still performed in the sequential device-discovery phase. I am not approving yet.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 044214d8-b337-4b2c-b368-975cf2ea166d
3c8cdb3 to
f87554f
Compare
Evangelink
left a comment
There was a problem hiding this comment.
Re-reviewed the updated implementation. The solution project and inner-TFM probes now run in parallel, while device selection and per-TFM device builds remain serialized in solution order. The previous cross-platform test issue and large-solution performance concern are addressed.
|
/backport to release/11.0.1xx |
|
Started backporting to |
|
@jonathanpeppers backporting to git am output$ git cherry-pick bb31fcacf528763377dce5113d04dcbec40eec7a
Auto-merging src/Cli/dotnet/Commands/Test/MTP/MSBuildUtility.cs
Auto-merging src/Cli/dotnet/Commands/Test/MTP/SolutionAndProjectUtility.cs
CONFLICT (content): Merge conflict in src/Cli/dotnet/Commands/Test/MTP/SolutionAndProjectUtility.cs
error: could not apply bb31fcacf5... [dotnet test] Fix device discovery for multi-targeted projects (#56054)
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: Fix dotnet test device discovery for inner builds
Using index info to reconstruct a base tree...
M src/Cli/dotnet/Commands/Test/MTP/MSBuildUtility.cs
M src/Cli/dotnet/Commands/Test/MTP/SolutionAndProjectUtility.cs
Falling back to patching base and 3-way merge...
Auto-merging src/Cli/dotnet/Commands/Test/MTP/MSBuildUtility.cs
Auto-merging src/Cli/dotnet/Commands/Test/MTP/SolutionAndProjectUtility.cs
CONFLICT (content): Merge conflict in src/Cli/dotnet/Commands/Test/MTP/SolutionAndProjectUtility.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 Fix dotnet test device discovery for inner builds
Error: The process '/usr/bin/git' failed with exit code 128 |
…d projects (#56170) ## Summary Backport of #56054 to `release/11.0.1xx`. Fixes `dotnet test` device discovery for multi-targeted Microsoft.Testing.Platform projects when workload-provided device targets are imported only by target-framework-specific inner builds. ## Backport details - Manually resolved the conflict in `SolutionAndProjectUtility.cs` against the release-specific implementation. - Preserves the original product and test coverage from #56054. - Contains a single commit on top of `release/11.0.1xx`. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Summary
Fixes
dotnet testdevice discovery for multi-targeted Microsoft.Testing.Platform projects when workload-provided device targets are imported only by target-framework-specific inner builds.This is the project shape produced by the experimental MAUI testing template in dotnet/maui-labs#444. Its
MauiTest1.csprojusesTargetFrameworksfor Android, iOS, and Mac Catalyst.Problem
For a project that declares
TargetFrameworks,dotnet testfirst evaluates the outer cross-targeting project. Workload-specific targets such as Android'sComputeAvailableDevicesare not imported into that outer evaluation; they become available only afterTargetFrameworkis set for an inner build.The existing pre-build device-selection logic checked the outer project's target table and returned early when
ComputeAvailableDeviceswas absent. As a result, plaindotnet testskipped device selection and continued into Android deployment without setting$(Device). Deployment then failed withXA0010: No available device, even thoughdotnet runlisted the available emulators anddotnet test -f net11.0-androidcorrectly entered device selection.The issue also affects the common single-entry form:
Although it contains only one framework, this is still evaluated as an outer cross-targeting project.
Fix
ComputeAvailableDevices.DeviceandRuntimeIdentifierthrough the existing per-TFM build, deployment, and test-launch pipeline.This matches the established
dotnet runanddotnet watchbehavior: workload capabilities are checked only after evaluating the selected inner TFM.Tests
ComputeAvailableDevicesonly whenTargetFrameworkis set.TargetFrameworkswithout-fand verify multiple devices are discovered.