Skip to content

Honor selected launch profile in bundled dotnet run - #19958

Merged
Karol Zadora-Przylecki (karolz-ms) merged 1 commit into
microsoft:mainfrom
gabisonia:fix/19867-bundled-launch-profile
Sep 14, 2026
Merged

Karol Zadora-Przylecki (karolz-ms) merged 1 commit into
microsoft:mainfrom
gabisonia:fix/19867-bundled-launch-profile

Conversation

@gabisonia

Copy link
Copy Markdown
Contributor

Description

With CLI bundles enabled, dotnet run --launch-profile http delegates to aspire run. The .NET SDK passes the selected profile through DOTNET_LAUNCH_PROFILE, but the Aspire launcher ignored it and selected the first profile again.

Use the effective DOTNET_LAUNCH_PROFILE value when no explicit Aspire launch-profile option is provided. This preserves the selection for both direct AppHost launch and the fallback to dotnet run; an explicit --launch-profile still takes precedence.

Fixes #19867

Validation

  • Reproduced three failing regression cases before the fix: inherited selection, context environment selection, and a missing inherited profile silently falling back to the default.
  • AppHost launcher unit tests: 154 passed, 1 skipped because the local filesystem is case-insensitive.
  • Full build and package generation: passed with no warnings or errors.
  • Both LaunchProfileTests end-to-end cases passed in Linux ARM64 Docker containers using a locally built CLI bundle. They run aspire run --launch-profile E2E and dotnet run --launch-profile E2E /p:AspireUseCliBundle=true, asserting the profile name, environment, application URL, and arguments observed by the running AppHost.

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
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
    • No

@github-actions

github-actions Bot commented Sep 4, 2026

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 -- 19958

Or

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

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

The precedence behavior is correctly implemented with focused unit and end-to-end regression coverage.

Pull request overview

Honors the launch profile selected by the .NET SDK when bundled execution delegates to Aspire.

Changes:

  • Uses DOTNET_LAUNCH_PROFILE when no explicit Aspire option is provided.
  • Adds unit coverage for precedence, defaults, and missing profiles.
  • Extends CLI end-to-end coverage to bundled dotnet run.
File summaries
File Description
src/Aspire.Cli/Projects/DotNetAppHostProject.cs Resolves the effective launch profile.
tests/Aspire.Cli.Tests/Projects/DotNetAppHostProjectTests.cs Tests profile selection and fallback behavior.
tests/Aspire.Cli.EndToEnd.Tests/LaunchProfileTests.cs Verifies explicit and bundled launch paths.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@gabisonia

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

@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.

@karolz-ms

Copy link
Copy Markdown
Contributor

PR #19958 review and issue #19867 verification

Result: No actionable review findings. The reported Windows failure reproduces with stable Aspire 13.5.3 and is fixed by the reviewed PR source.

Revision and scope

The production change is in DotNetAppHostProject.RunAsync. It uses the effective DOTNET_LAUNCH_PROFILE value only when the explicit Aspire option is absent. The resulting selection reaches both direct AppHost launch and the dotnet run fallback.

Explicit aspire run --launch-profile support was already present in the parent branch through #19494. This PR adds the missing inherited-profile handoff needed when the SDK redirects bundled dotnet run into Aspire.

Behavioral impact and coverage

Surface Behavior checked Evidence
Bundled SDK launch A non-first profile selected by dotnet run survives delegation Real Windows reproduction and added regression tests
Direct Aspire launch Explicit selection and environment-only selection choose the intended profile Real Windows AppHosts and unit tests
Selection precedence Explicit option overrides inherited selection; context environment overrides inherited environment Windows explicit-override scenario and unit tests
Default selection An absent or empty selection preserves the first supported profile Windows default scenario and unit tests
SDK fallback Inherited selection is forwarded when direct launch is disabled; missing profiles do not select the default Windows fallback/missing scenarios and runner tests

The E2E change exercises both explicit Aspire selection and the SDK bundle hook, checking the profile name, profile-specific environment variable, arguments, and application URL. Existing runner tests cover forwarding to project, single-file, and watch commands. No new test project, runtime package input, CI job, or test eligibility change was introduced.

Environment and artifact identity

  • Host: Windows x64.
  • .NET SDK used: 10.0.400, restored with the repository's restore script.
  • Baseline CLI, templates, and AppHost packages: stable 13.5.3; installed CLI reports 13.5.3+b5f143315ffb6968ea939a9978797a5b20e4c688.
  • PR CLI: built from the exact checked-out PR source; reports 13.6.0-dev. No CLI identity emulation was used.
  • Runtime scenarios retained the released 13.5.3 AppHost SDK/packages and bundle components, varying the CLI executable. Bundled SDK invocations pinned that executable using /p:AspireCliPath=<cli-path>.
  • Each scenario used a fresh generated project. An empty running AppHost recorded its actual environment and arguments on ApplicationStarted, then shut down automatically. Ports were dynamically allocated.
  • The installed stable CLI was not replaced.

Focused tests and negative control

Ran DotNetAppHostProjectTests and DotNetCliRunnerTests with MTP-native filters and both quarantined/outerloop exclusions:

dotnet test --project tests\Aspire.Cli.Tests\Aspire.Cli.Tests.csproj --no-launch-profile -p:SkipNativeBuild=true -- --filter-class '*.DotNetAppHostProjectTests' --filter-class '*.DotNetCliRunnerTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'

225 total: 222 passed, 3 platform-specific skips, 0 failures.

To verify that the new tests detect the bug, temporarily changed only the production selection expression back to context.LaunchProfile and ran the two new/expanded regression methods:

  • Inherited http selected https instead.
  • Context environment selection produced the default profile's environment instead.
  • A missing inherited profile incorrectly entered direct launch using the default.

Negative control: 3 failed, 4 passed. Restored the PR expression and reran the same cases: 7 passed, 0 failures. All temporary production edits were removed.

Windows runtime scenarios

All nine processes reached AppHost startup and exited with code 0. For the seven PR scenarios, assertions checked the complete profile name, marker, argument list, and application URL.

Scenario Observed profile/marker Result
Stable: dotnet run --launch-profile http, bundle enabled https / https Reproduced #19867
Stable: same command, bundle disabled http / http Confirmed documented workaround
PR: dotnet run --launch-profile http, bundle enabled http / http Fixed
PR: aspire run --launch-profile http http / http Passed
PR: DOTNET_LAUNCH_PROFILE=http, no explicit option http / http Passed
PR: explicit https with inherited http https / https Passed
PR: no explicit or inherited selection https / https Passed
PR: inherited missing missing / no profile marker; no profile arguments No silent default substitution
PR: inherited http, direct launch disabled http / http SDK fallback preserved selection

The http profile produced --profile-marker http and http://127.0.0.1:0; the https profile produced --profile-marker https and https://127.0.0.1:0;http://127.0.0.1:0.

Limits and cleanup

  • PR CI remains action_required, awaiting maintainer approval: https://github.com/microsoft/aspire/actions/runs/33918315884 . This review did not approve or trigger CI.
  • Consequently, this validates the PR source, not an official packaged PR artifact. The Linux-only Hex1b E2E suite was reviewed but not independently executed; real Windows scenarios exercised the relevant commands instead.
  • The reporter used .NET 11 preview 7. The local reproduction and fix verification used .NET 10.0.400; the exact preview SDK was not tested.
  • Confirmed the remote PR head still matched the reviewed commit and the repository had no source changes.
  • All temporary AppHost projects were removed and no reproduction processes remained. The nine structured startup observations and reproduction fixtures were retained as private session artifacts.

@karolz-ms

Copy link
Copy Markdown
Contributor

PR #19958 testing report

Result: PASS for the tested launch-profile behavior. Seven Windows runtime scenarios passed, the focused launcher suite passed 209 tests with five platform skips, and both modified Linux E2E cases passed in the approved CI run.

PR and artifact information

Item Value
PR #19958 - Honor selected launch profile in bundled dotnet run
Related issue #19867
Tested commit ebd438621bfebb056655e5625cafad99847d0072
Dogfood CLI version 13.6.0-pr.19958.gebd43862
Artifact verification Passed: embedded short SHA ebd43862 matches the PR head; the producing CI run also identifies the full tested SHA
Windows environment Windows 11 Enterprise, build 10.0.26200, x64
Local .NET SDK 10.0.400, bootstrapped from the PR's pinned configuration
Test date September 14, 2026; testing and temporary-workspace cleanup completed by 17:43 UTC
CI run 33918315884

CI initially required contributor-workflow approval. After explicit approval, the Windows CLI was installed using the PR's dogfood script with an isolated -InstallPath, -SkipPath, and -SkipExtension. The required artifacts were cli-native-archives-win-x64, built-nugets, and built-nugets-for-win-x64.

The source tests ran from a separate, clean checkout of the exact PR commit, not this session's newer main checkout. The PR head was rechecked after the runtime scenarios and remained unchanged.

Changes analyzed

  • src\Aspire.Cli\Projects\DotNetAppHostProject.cs: use the effective DOTNET_LAUNCH_PROFILE when there is no explicit Aspire launch-profile option, for both direct launch and the SDK fallback.
  • tests\Aspire.Cli.Tests\Projects\DotNetAppHostProjectTests.cs: inherited/context/default selection and missing-profile regression coverage.
  • tests\Aspire.Cli.EndToEnd.Tests\LaunchProfileTests.cs: exercise both aspire run and bundled dotnet run, including application URL propagation.

Only CLI implementation and its unit/E2E tests changed. There were no hosting integration, dashboard, template, VS Code extension, or CI infrastructure changes.

1. Launcher regression suite

Status: Passed - 209 passed, 0 failed, 5 skipped, 214 total.

The selected classes were DotNetAppHostProjectTests and AppHostLauncherTests. Quarantined and outerloop tests were excluded.

.\restore.cmd -projects tests\Aspire.Cli.Tests\Aspire.Cli.Tests.csproj /p:SkipNativeBuild=true

dotnet test `
  --project tests\Aspire.Cli.Tests\Aspire.Cli.Tests.csproj `
  --no-launch-profile --no-restore `
  --results-directory $evidenceDir `
  -- `
  --filter-class "*.DotNetAppHostProjectTests" `
  --filter-class "*.AppHostLauncherTests" `
  --filter-not-trait "quarantined=true" `
  --filter-not-trait "outerloop=true" `
  --report-trx --report-trx-filename launcher-regressions.trx

All seven new or expanded regression cases executed and passed: the five inherited/context/default selection rows and both explicit/inherited missing-profile rows. These include context environment taking precedence over the inherited environment.

The five skips cover Windows case-sensitivity, symlink availability, and Unix-only process behavior; none is a new launch-profile regression case.

Evidence: launcher-regressions.trx, launcher-regressions-attempt2.txt, and restore.txt.

2. Windows runtime scenarios

Status: All seven distinct scenarios passed.

Each executed scenario used a fresh aspire new aspire-starter project, explicitly selecting the PR package hive and exact package version. Creation disabled Redis, test-project generation, localhost-TLD prompts, and agent initialization. The generated AppHost was checked for the exact PR SDK version and AspireUseCliBundle=true.

The AppHost source was replaced with a small profile-observation fixture. Two launch profiles were installed in deliberate order: https first and http second. Each has distinct profile markers, command-line arguments, and application URLs. Endpoints used dynamic loopback ports.

For every passing scenario, the harness compared the complete observed profile JSON with the expected object, confirmed AppHost startup, successfully queried aspire describe, and stopped that specific AppHost using aspire stop --apphost. No global stop command was used.

Scenario Coverage Verified result Evidence directory
Bundled dotnet run --launch-profile http /p:AspireUseCliBundle=true Original repro / happy path Non-first http profile selected; marker, arguments, and application URL preserved windows-bundled\bundled-dotnet-http
aspire run --launch-profile http Happy path Explicit profile selected windows-cli\aspire-explicit-http
aspire run with inherited DOTNET_LAUNCH_PROFILE=http Happy path Inherited profile selected windows-cli\aspire-inherited-http
Explicit https with inherited http Precedence boundary Explicit option wins, including its marker, arguments, and HTTPS URL windows-cli\explicit-overrides-inherited
No explicit or inherited selection Default boundary First https profile selected windows-retry\default-profile-unset
Empty inherited selection Empty-value boundary First https profile selected windows-cli\default-profile-empty
Inherited nonexistent missing profile Unhappy path / SDK fallback Missing name forwarded to dotnet run; no default-profile marker or arguments applied; SDK diagnostic logged windows-missing-final\missing-inherited-profile

Original repro: proof of bundle delegation

The live process tree contained the exact verified dogfood aspire.exe beneath dotnet.exe, followed by the generated AppHost executable. This rules out a false pass from ordinary, non-bundled dotnet run.

The running AppHost reported:

{
  "selectedProfile": "selected-profile",
  "launchProfile": "http",
  "arguments": [
    "--profile-argument",
    "selected-profile"
  ],
  "applicationUrl": "http://127.0.0.1:0"
}

Missing inherited profile: expected fallback behavior

The process tree showed the SDK dotnet.exe fallback rather than direct AppHost launch. The CLI diagnostic log recorded:

run --no-build --launch-profile=missing --project <apphost> --
The launch profile "missing" could not be applied.
A launch profile with the name 'missing' doesn't exist.

The AppHost reported selectedProfile: null, launchProfile: "missing", and an empty argument array. It did not receive the first profile's settings. As with the SDK's missing-profile behavior, the application continued without applying a launch profile; this is not a nonzero-exit validation case.

The diagnostic is captured in the CLI's log, not its normal run-console output.

3. Modified Linux E2E cases

Status: Passed - 2 executed, 2 passed, 0 failed, 0 skipped.

The focused CI job ran on the tested PR commit. Its downloaded TRX confirms both theory rows executed:

Case Result Duration
RunStartsAppHostWithSelectedLaunchProfile(useDotNetRun: False) Passed 25.8 s
RunStartsAppHostWithSelectedLaunchProfile(useDotNetRun: True) Passed 22.4 s

These are CI results, not a claim that the Linux-only Hex1b harness ran locally on Windows.

Evidence: ci-launchprofiles\testresults\Cli.EndToEnd-LaunchProfileTests.trx and ci-recordings\RunStartsAppHostWithSelectedLaunchProfile.cast.

Setup observations and limitations

  • Two initial Windows attempts stopped during project creation, before exercising launch-profile behavior: one reported conflicting installed 13.5/13.6 templates, and another reported a missing aspire-starter template. Retrying with DOTNET_CLI_HOME isolated inside the temporary test root resolved creation. HOME, USERPROFILE, and APPDATA were not overridden. These setup failures are retained and are not attributed to the PR's launch-profile change.
  • One harness assertion initially searched the normal console for the missing-profile diagnostic. Inspection confirmed the expected SDK diagnostic in the CLI log. A fresh rerun verified that actual log sink, the forwarded --launch-profile=missing argument, and the SDK fallback process. All ten Windows attempt records are preserved, including these three unsuccessful setup/assertion attempts.
  • The original issue's .NET 11 preview SDK was not separately tested. Local runtime coverage used the repository-pinned .NET 10 SDK.
  • The broader CI run was still in progress at the final status check. Only the focused CI E2E job and the explicitly described local checks are claimed as passed.
  • No dashboard UI changed, so no dashboard screenshots or browser automation were required.

Evidence and cleanup

The report, reproducible PowerShell harness, C# and launch-settings fixtures, full expected/observed JSON, exact commands, process snapshots, stdout/stderr, CLI diagnostic logs, unit/CI TRX files, and terminal recording are retained in the session's pr-19958 artifact directory. Raw local logs have not been uploaded to the PR.

verification-summary.json records all attempts and the seven passing final Windows results. cleanup.json confirms that all owned AppHosts and temporary SDK build servers stopped and the temporary source checkout, CLI installation, and generated apps were removed.

No files in the working repository were changed. No user PATH, VS Code extension, or certificate trust-store changes were made.

Overall conclusion

The tested PR build honors inherited launch-profile selection in bundled dotnet run, preserves explicit-option precedence, retains normal default selection, and forwards invalid inherited selections to the SDK without silently substituting the first profile. No launch-profile regression was found in the tested scope.

@karolz-ms
Karol Zadora-Przylecki (karolz-ms) merged commit e5714ca into microsoft:main Sep 14, 2026
339 of 344 checks passed
@github-actions github-actions Bot added this to the 13.6 milestone Sep 14, 2026
@karolz-ms

Copy link
Copy Markdown
Contributor

Irakli Gabisonia (@gabisonia) many thanks for helping us make Aspire better! 🤗

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ CI Failure Analysis: Possible Flaky Test(s)

The CI build failed due to test failure(s) that appear unrelated to the PR changes. These may be flaky tests.

Suspected flaky test(s):

  • Aspire dynamic debug configuration E2E "after each" hook for "re-resolves the selected AppHost by dynamic configuration name in duplicate-alias workspaces" in job Tests / Run VS Code extension E2E tests / VS Code extension E2E (Windows, dynamic-debug-configuration)
    • Error: Dynamic debug configuration E2E teardown failed.
  1. Error: EBUSY: resource busy or locked, rmdir 'C:\Users\runneradmin\AppData\Local\Temp\aev-1vmxmS\workspace.e2e-dynamic-debug\first'
  • Stack Trace (first frames):
AggregateError: Dynamic debug configuration E2E teardown failed.
1. Error: EBUSY: resource busy or locked, rmdir 'C:\Users\runneradmin\AppData\Local\Temp\aev-1vmxmS\workspace\.e2e-dynamic-debug\first'
    at runE2eTeardown (out\test-e2e\test-e2e\helpers\fixtures.js:217:15)
    at async Context.<anonymous> (out\test-e2e\test-e2e\dynamicDebugConfiguration.e2e.test.js:62:9)
  • Why likely flaky: The failure is in the test teardown (after-each hook) attempting to rmdir a Windows temp directory that is still locked (EBUSY), not in the test body itself. The PR only changes src/Aspire.Cli/Projects/DotNetAppHostProject.cs and CLI-specific tests; it does not touch the VS Code extension E2E fixtures or dynamic debug configuration workspace cleanup code, so this is an environmental/timing issue unrelated to the PR.

Suggested actions:

  • Re-run the failed CI jobs to confirm if the failure is intermittent
  • If the test continues to fail, consider quarantining it using /quarantine-test <test name> <issue URL>
  • Search existing issues to see if this test is already known to be flaky

You can re-run the failed jobs from the workflow run page.

@github-actions github-actions Bot locked and limited conversation to collaborators Oct 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dotnet run --launch-profile ignored when AspireUseCliBundle is true

3 participants