Skip to content

Guard MTP test targets with IsTestingPlatformApplication to prevent interference with VSTest projects#7539

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-usemsbuildtestinfrastructure-issues
Draft

Guard MTP test targets with IsTestingPlatformApplication to prevent interference with VSTest projects#7539
Copilot wants to merge 2 commits intomainfrom
copilot/fix-usemsbuildtestinfrastructure-issues

Conversation

Copy link
Contributor

Copilot AI commented Mar 12, 2026

When UseMSBuildTestInfrastructure=true is set (e.g., in Directory.Build.props), the MTP.MSBuild package was hooking MTP-specific execution logic into VSTest projects that never opted into MTP (IsTestingPlatformApplication != true).

Changes

  • Microsoft.Testing.Platform.MSBuild.targets: Added AND '$(IsTestingPlatformApplication)' == 'true' to _MTPTestTarget's condition — prevents InvokeTestingPlatform from running AfterTargets="Test" on non-MTP projects when UseMSBuildTestInfrastructure=true.

  • Microsoft.Testing.Platform.MSBuild.CustomTestTarget.targets: Added the same guard to the Test target — prevents MTP's custom Test target from overriding SDK behavior for non-MTP projects when UseMSBuildTestInfrastructure=false.

Both are target-level conditions (evaluated at runtime), so they correctly observe the final settled value of IsTestingPlatformApplication, including cases where MSTest.TestAdapter.targets sets it to false after the package's targets are imported.


📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issues with UseMSBuildTestInfrastructure not opting-in MTP Guard MTP test targets with IsTestingPlatformApplication to prevent interference with VSTest projects Mar 12, 2026
Copilot AI requested a review from Evangelink March 12, 2026 21:00
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.

Setting UseMSBuildTestInfrastructure causes issues when not opting-in MTP

2 participants