Skip to content

Suppress AppHost CLI run hook for MTP tests - #22381

Merged
Damian Edwards (DamianEdwards) merged 2 commits into
microsoft:mainfrom
afscrome:alexanderc-trayport-fix-mtp-migration-issue
Nov 19, 2026
Merged

Damian Edwards (DamianEdwards) merged 2 commits into
microsoft:mainfrom
afscrome:alexanderc-trayport-fix-mtp-migration-issue

Conversation

@afscrome

@afscrome Alex Crome (afscrome) commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Description

MTP test applications that reference Aspire.Hosting.AppHost were launched through the Aspire CLI run hook instead of their generated test entry point, preventing dotnet test from running tests. Suppress the hook when IsTestingPlatformApplication is true, while retaining the existing CLI hook behavior for non-test AppHosts. Add an AppHost SDK regression test for the MTP property.

Testing prerequisite: Tests that call DistributedApplicationTestingBuilder.Create() must reference the Aspire.Hosting.AppHost package so the test assembly has the AppHost metadata needed to locate and load the AppHost. Aspire.Hosting.Testing alone does not provide that metadata.

The regression test was verified both ways:

  • Without the fix: failed because it expected the normal dotnet run command but got aspire.exe.
  • With the fix: passed.

Validation command:

dotnet test --project tests\Aspire.Hosting.Sdk.Tests\Aspire.Hosting.Sdk.Tests.csproj --no-launch-profile -- --filter-method "*.ComputeRunArgumentsDoesNotUseAspireCliForMtpTestApplications" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"

Result with the fix: passed (1 test); without the fix: failed (1 test), as expected.

Fixes #22382

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 18, 2026 09:20
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 22381

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 22381"

@github-actions github-actions Bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Nov 18, 2026

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.

🟡 Changes recommended

The regression test can pass without the fix when no usable CLI is available, so it needs a supported fake CLI and disabled suppression inputs to isolate the new MTP condition.

1 open issue
What changed in this PR

Prevents Microsoft.Testing.Platform (MTP) test applications that reference Aspire.Hosting.AppHost from being launched through the Aspire CLI, addressing #22382.

Changes:

  • Suppresses the CLI run hook when IsTestingPlatformApplication is true, preserving existing behavior for non-test AppHosts.
  • Adds an SDK regression test asserting that MTP applications retain their native run command.
File Description
tests/​Aspire.Hosting.Sdk.Tests/​AppHostSdkTargetsTests.cs Adds regression coverage for MTP run-hook suppression.
src/​Aspire.Hosting.AppHost/​build/​Aspire.Hosting.AppHost.in.targets Adds the MTP property check to CLI run-hook suppression.

Review effort: Balanced

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@afscrome

Copy link
Copy Markdown
Contributor Author

Jose Perez Rodriguez (@joperezr) Any chance we could consider this for a hotfix.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

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 block the change intended to preserve MTP test entry points.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@DamianEdwards

Copy link
Copy Markdown
Member

/backport to release/17.0

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/17.0 (link to workflow run)

@DamianEdwards Damian Edwards (DamianEdwards) added area-testing and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Nov 19, 2026
@DamianEdwards
Damian Edwards (DamianEdwards) merged commit caee371 into microsoft:main Nov 19, 2026
918 of 928 checks passed
@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 17.1 milestone Nov 19, 2026
@afscrome
Alex Crome (afscrome) deleted the alexanderc-trayport-fix-mtp-migration-issue branch November 19, 2026 23:01
Jose Perez Rodriguez (joperezr) pushed a commit that referenced this pull request Nov 20, 2026
Backport of #22381 to release/17.0

/cc @DamianEdwards @afscrome

## Customer Impact

## Testing

## Risk

## Regression?

---------

Co-authored-by: Alex Crome <afscrome@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This was referenced Dec 5, 2026
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.

MTP test projects referencing AppHost package launch Aspire CLI instead of tests

3 participants