Skip to content

Gate dotnet test --solution device selection on IsTestingPlatformApplication only - #57182

Merged
Evangelink merged 5 commits into
mainfrom
dev/amauryleve/57142-followup-mtp-device-gate
Nov 25, 2026
Merged

Evangelink merged 5 commits into
mainfrom
dev/amauryleve/57142-followup-mtp-device-gate

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Follow-up to #57142 (fix for #57120), applying review feedback from the release/11.0.1xx backport #57151 (review).

Change

#57142 limited dotnet test --solution device selection to projects with IsTestProject or IsTestingPlatformApplication set. IsTestProject is a VSTest concept and is irrelevant for MTP:

  • Only IsTestingPlatformApplication projects are deployed (GetModuleFromProject → DeployAndGetRunProperties).
  • IsTestProject-only projects are collected only so MTP mode can reject them with the VSTest-unsupported error.

With the previous gate, a VSTest project whose inner build imports ComputeAvailableDevices was asked for a device, so the run failed with No devices are available for this project. instead of the VSTest-unsupported error.

This PR:

  • Gates solution device selection on IsTestingPlatformApplication only, and renames requireTestProject/RequireTestProject to requireTestingPlatformApplication/RequireTestingPlatformApplication.
  • Adds ItDoesNotSelectDevicesForVSTestProjectsInSolution and extracts the shared project setup of ItDoesNotSelectDevicesForNonTestProjectsInSolution into a helper.
  • Updates the src/Cli/AGENTS.md device-selection note.

The single-project path and --device handling are unchanged.

Validation

On this branch (head 5c7fb36477a277557387618dee0fa73de829c570, based on main at 81ad515a6c8d47882a99ad85d0ad76ac5c8ae1c5) with a full build.cmd redist layout:

  • With only SolutionAndProjectUtility.cs and MSBuildUtility.cs reverted to main, ItDoesNotSelectDevicesForVSTestProjectsInSolution fails with No devices are available for this project.
  • With the fix, all 47 tests in GivenDotnetTestSelectsDevice pass.

The same change was validated on release/11.0.1xx in #57151 (commit e068010513d6617b2ab8653b2438152a95febc8b): the new test fails with the previous gate, and all 40 GivenDotnetTestSelectsDevice tests pass with the fix.

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]>
(cherry picked from commit e068010)
@Evangelink
Evangelink requested review from a team, lbussell and mthalman as code owners November 17, 2026 20:50
Copilot AI balanced review requested due to automatic review settings November 17, 2026 20:50
@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

There are no active review issues for the change restricting solution-level device selection to Microsoft.Testing.Platform applications.

No open issues 🎉

What changed in this PR

This PR refines the earlier device-selection fix so dotnet test --solution selects devices only for Microsoft.Testing.Platform applications. VSTest-only projects can then reach the intended unsupported-project error rather than fail during device discovery.

Changes:

  • Restricts solution device selection to IsTestingPlatformApplication and renames the corresponding gate.
  • Adds VSTest regression coverage and extracts shared test-project setup.
  • Updates CLI guidance; single-project behavior and --device handling remain unchanged.
File Description
test/​dotnet.Tests/​CommandTests/​Test/​GivenDotnetTestSelectsDevice.cs Adds VSTest regression coverage and shares project setup.
src/​Cli/​dotnet/​Commands/​Test/​MTP/​SolutionAndProjectUtility.cs Restricts the device-selection gate to MTP applications.
src/​Cli/​dotnet/​Commands/​Test/​MTP/​MSBuildUtility.cs Uses the renamed gate for solution evaluation.
src/​Cli/​AGENTS.md Documents MTP-only solution device selection.

Review effort: Balanced

@Evangelink
Evangelink disabled auto-merge November 25, 2026 09:33
@Evangelink
Evangelink enabled auto-merge (squash) November 25, 2026 09:33
@Evangelink
Evangelink merged commit f8e69e5 into main Nov 25, 2026
25 checks passed
@Evangelink
Evangelink deleted the dev/amauryleve/57142-followup-mtp-device-gate branch November 25, 2026 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants