Repository navigation
[release/11.0.1xx] Only select devices for test projects in dotnet test --solution - #57151
Merged
Evangelink merged 2 commits intoNov 18, 2026
Merged
Conversation
Co-authored-by: Copilot App <[email protected]> (cherry picked from commit 75c968b)
Evangelink
requested review from
a team,
lbussell and
mthalman
as code owners
November 16, 2026 17:04
|
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 were identified for the change limiting solution-level device selection to test projects.
No open issues 🎉
What changed in this PR
Backports the fix for #57120 to release/11.0.1xx, preventing non-test projects such as MAUI apps from blocking dotnet test --solution with device-selection errors.
Changes:
- Limits solution device selection to projects marked
IsTestProjectorIsTestingPlatformApplication, preserving single-project behavior. - Adds regression coverage for a solution containing device tests and a non-test app that reports no devices.
- Documents the solution-only restriction and its dependency on post-restore evaluation.
| File | Description |
|---|---|
test/dotnet.Tests/CommandTests/Test/GivenDotnetTestSelectsDevice.cs |
Adds coverage verifying non-test projects skip device discovery and deployment. |
src/Cli/dotnet/Commands/Test/MTP/SolutionAndProjectUtility.cs |
Adds an optional test-project gate to device-selection checks. |
src/Cli/dotnet/Commands/Test/MTP/MSBuildUtility.cs |
Enables the gate for solution runs after restore and build. |
src/Cli/AGENTS.md |
Documents device-selection behavior and why single-project runs remain unchanged. |
Review effort: Balanced
Youssef1313
reviewed
Nov 16, 2026
IsTestProject is a VSTest concept and is irrelevant for MTP. VSTest projects are never deployed and are rejected later with the VSTest-unsupported error, so they must not opt into device selection. Previously, a VSTest project whose inner build imported ComputeAvailableDevices failed with "No devices are available" instead. Adds ItDoesNotSelectDevicesForVSTestProjectsInSolution. Co-authored-by: Copilot App <[email protected]>
JanKrivanek
approved these changes
Nov 18, 2026
Evangelink
had a problem deploying
to
copilot-pat-pool
November 18, 2026 10:52 — with
GitHub Actions
Failure
This was referenced Nov 18, 2026
This branch had an error being deployed
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.
Backport of #57142 to release/11.0.1xx.
Fixes #57120 for the 11.0.1xx servicing line.
This is a manual backport because the automatic
/backportworkflow run 43893227156 hit a conflict insrc/Cli/AGENTS.md.Conflict resolution
MSBuildUtility.cs,SolutionAndProjectUtility.cs) and the test (GivenDotnetTestSelectsDevice.cs) cherry-picked without conflicts. They are identical to Only select devices for test projects in dotnet test --solution #57142.src/Cli/AGENTS.md:release/11.0.1xxdoes not havemain's "MTP build preparation" section that Only select devices for test projects in dotnet test --solution #57142 extended. I added only the device-selection paragraph from Only select devices for test projects in dotnet test --solution #57142 under a new## MTP device selectionheading and did not bring in the rest ofmain's section.Review follow-up
Per review feedback,
IsTestProjectis a VSTest concept and is irrelevant for MTP, so commit e068010 gates solution device selection onIsTestingPlatformApplicationonly and addsItDoesNotSelectDevicesForVSTestProjectsInSolution. The same change is going tomainin #57182.Tactics
Summary
In 11.0,
dotnet test --solutionchecks every project in the solution for theComputeAvailableDevicestarget to decide whether it needs to pick a device. .NET MAUI app and library projects import that target through the MAUI workload even though they are not test projects. When one of them reports no devices, or several, the whole run fails before any tests run. The fix limits device selection in--solutionruns to Microsoft.Testing.Platform test applications (IsTestingPlatformApplicationistrue). That evaluation runs after the solution is restored and built, so the property is reliable. The single-project (--project) path is unchanged.Customer Impact
Any
dotnet test --solutionrun with SDK 11.0.100 fails if the solution has a .NET MAUI app or library project next to regular test projects, even when the tests target plainnet10.0/net11.0and never need a device. The command exits with code 1 and printsNo devices are available for this project.orUnable to run this project because multiple devices are available.... No tests run. Customer report: #57120, from GitHub Actions runners that picked up SDK 11. The same command works with SDK 10.0.404. Possible workarounds (not validated): rundotnet test --projectfor each test project, or use a solution filter (.slnf) that leaves out the MAUI projects.Regression?
Yes. Introduced in 11.0.1xx by #56170 (backport of #56054, "Fix dotnet test device discovery for multi-targeted projects"), which made
--solutionruns check each project's inner build forComputeAvailableDevices. Reproduced with SDK 11.0.100; SDK 10.0.404 works.Testing
ItDoesNotSelectDevicesForNonTestProjectsInSolutioninGivenDotnetTestSelectsDevice. It uses a solution with a device test project plus a non-test project that importsComputeAvailableDevicesonly in its inner build and reports zero devices. Onmain, it fails without the fix (No devices are available) and passes with it.main(Only select devices for test projects in dotnet test --solution #57142), all 46 tests inGivenDotnetTestSelectsDevicepass against a locally built redist SDK, and Only select devices for test projects in dotnet test --solution #57142's CI passed.release/11.0.1xx(head7a602ae3bfd9d55a3eb0c779dd9da3f0ada7cb36), with a fullbuild.cmdredist layout: all 39 tests inGivenDotnetTestSelectsDevicepass, including the new test. With only the two product files reverted torelease/11.0.1xxanddotnet.dllrebuilt, the new test fails withNo devices are available for this project.; after restoring the fix it passes again.e068010513d6617b2ab8653b2438152a95febc8b): new testItDoesNotSelectDevicesForVSTestProjectsInSolutioncovers a VSTest project (IsTestProjectonly) that importsComputeAvailableDevicesand reports zero devices. With the previousIsTestProjectgate it fails withNo devices are available for this project.; with the follow-up it reports the expected VSTest-unsupported error instead. All 40 tests inGivenDotnetTestSelectsDevicepass.Risk
Low. The product change is about 30 lines in two files and only affects how
dotnet test --solutiondecides whether a project needs a device. Test projects that importComputeAvailableDevices(device test projects) still get device selection. The only behavior change is that projects in a solution that are not MTP test applications are no longer asked for a device. OnlyIsTestingPlatformApplicationprojects are deployed and run byGetModuleFromProject;IsTestProject-only (VSTest) projects are rejected in MTP mode with an explicit error, so a project excluded from device selection would never have been deployed or run anyway. The single-project path and--devicehandling are unchanged.