Skip to content

[release/11.0.1xx] Only select devices for test projects in dotnet test --solution - #57151

Merged
Evangelink merged 2 commits into
release/11.0.1xxfrom
backport/pr-57142-to-release/11.0.1xx
Nov 18, 2026
Merged

Evangelink merged 2 commits into
release/11.0.1xxfrom
backport/pr-57142-to-release/11.0.1xx

Conversation

@Evangelink

@Evangelink Evangelink commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

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 /backport workflow run 43893227156 hit a conflict in src/Cli/AGENTS.md.

Conflict resolution

Review follow-up

Per review feedback, IsTestProject is a VSTest concept and is irrelevant for MTP, so commit e068010 gates solution device selection on IsTestingPlatformApplication only and adds ItDoesNotSelectDevicesForVSTestProjectsInSolution. The same change is going to main in #57182.

Tactics

Summary

In 11.0, dotnet test --solution checks every project in the solution for the ComputeAvailableDevices target 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 --solution runs to Microsoft.Testing.Platform test applications (IsTestingPlatformApplication is true). 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 --solution run 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 plain net10.0/net11.0 and never need a device. The command exits with code 1 and prints No devices are available for this project. or Unable 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): run dotnet test --project for 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 --solution runs check each project's inner build for ComputeAvailableDevices. Reproduced with SDK 11.0.100; SDK 10.0.404 works.

Testing

  • New test ItDoesNotSelectDevicesForNonTestProjectsInSolution in GivenDotnetTestSelectsDevice. It uses a solution with a device test project plus a non-test project that imports ComputeAvailableDevices only in its inner build and reports zero devices. On main, it fails without the fix (No devices are available) and passes with it.
  • On main (Only select devices for test projects in dotnet test --solution #57142), all 46 tests in GivenDotnetTestSelectsDevice pass against a locally built redist SDK, and Only select devices for test projects in dotnet test --solution #57142's CI passed.
  • I reproduced the issue manually on SDK 11.0.100 and confirmed SDK 10.0.404 succeeds.
  • On release/11.0.1xx (head 7a602ae3bfd9d55a3eb0c779dd9da3f0ada7cb36), with a full build.cmd redist layout: all 39 tests in GivenDotnetTestSelectsDevice pass, including the new test. With only the two product files reverted to release/11.0.1xx and dotnet.dll rebuilt, the new test fails with No devices are available for this project.; after restoring the fix it passes again.
  • Review follow-up (head e068010513d6617b2ab8653b2438152a95febc8b): new test ItDoesNotSelectDevicesForVSTestProjectsInSolution covers a VSTest project (IsTestProject only) that imports ComputeAvailableDevices and reports zero devices. With the previous IsTestProject gate it fails with No devices are available for this project.; with the follow-up it reports the expected VSTest-unsupported error instead. All 40 tests in GivenDotnetTestSelectsDevice pass.
  • Not validated: an end-to-end run against a real MAUI solution such as the one in [11.0 regression] dotnet test error: No devices are available for this project #57120.

Risk

Low. The product change is about 30 lines in two files and only affects how dotnet test --solution decides whether a project needs a device. Test projects that import ComputeAvailableDevices (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. Only IsTestingPlatformApplication projects are deployed and run by GetModuleFromProject; 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 --device handling are unchanged.

@Evangelink
Evangelink requested review from a team, lbussell and mthalman as code owners November 16, 2026 17:04
Copilot AI balanced review requested due to automatic review settings November 16, 2026 17:04
@azure-pipelines

Copy link
Copy Markdown
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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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 IsTestProject or IsTestingPlatformApplication, 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

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]>
@Evangelink
Evangelink merged commit 657d22a into release/11.0.1xx Nov 18, 2026
27 of 28 checks passed
@Evangelink
Evangelink deleted the backport/pr-57142-to-release/11.0.1xx branch November 18, 2026 10:52

This branch had an error being deployed

1 failed deployment
copilot-pat-pool — e0680105 Deployed Nov 18, 2026 by Evangelink via pre_activation #14649
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants