Repository navigation
Fix VS Code AppHost launch path resolution - #17408
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 17408Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 17408" |
There was a problem hiding this comment.
Pull request overview
This PR fixes Aspire VS Code extension launch path handling so that when users start an Aspire debug session from an SDK-style C# AppHost source file (typically Program.cs), the extension resolves that source path to the containing AppHost project (.csproj) before invoking the Aspire CLI via --apphost.
Changes:
- Added
resolveAppHostLaunchPathutility to normalize C# AppHost launch paths (Program.cs→ containing project; single-file#:sdk Aspire.AppHost.Sdkstays as source). - Updated
AspireEditorCommandProvider.getAppHostPath()to return the normalized launch path when launching from the active editor. - Updated
AspireDebugConfigurationProvider.resolveDebugConfigurationWithSubstitutedVariables()to normalizelaunch.jsonprogramvalues post-substitution, with unit tests covering key scenarios.
Show a summary per file
| File | Description |
|---|---|
| extension/src/utils/appHostLaunchPath.ts | Introduces the path normalization logic for C# AppHost launches. |
| extension/src/editor/AspireEditorCommandProvider.ts | Uses normalization when launching from the active editor’s AppHost file. |
| extension/src/debugger/AspireDebugConfigurationProvider.ts | Normalizes program after variable substitution for launch configs. |
| extension/src/test/aspireEditorCommandProvider.test.ts | Adds unit tests for active-editor launch path normalization. |
| extension/src/test/aspireDebugConfigurationProvider.test.ts | Adds unit tests for launch configuration normalization behavior. |
Copilot's findings
- Files reviewed: 5/5 changed files
- Comments generated: 1
|
Replying to Copilot review overview #17408 (review): thanks for the review. The PR has since been refactored from the original |
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
James Newton-King (JamesNK)
left a comment
There was a problem hiding this comment.
Reviewed the AppHost discovery refactor. Found 2 issues:\n\n- 1 resource leak/correctness issue: Spawned CLI process in runCliForStdout is never tracked — no timeout, no kill-on-dispose, and a hung process permanently blocks the cached discovery promise for the workspace.\n- 1 performance issue: File system watchers use broad **/*.csproj patterns without excluding build output directories, which can trigger excessive CLI re-invocations during builds in large workspaces.
Co-authored-by: Copilot <[email protected]>
|
Replying to review summary #17408 (review): thanks, agreed on both points. I addressed the inline threads in c3c8505 by adding discovery CLI timeout/cancellation on dispose and filtering watcher invalidations for output and vendor directories. |
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
|
Re-running the failed jobs in the CI workflow for this pull request because 1 job was identified as retry-safe transient failures in the CI run attempt.
|
James Newton-King (JamesNK)
left a comment
There was a problem hiding this comment.
1 issue found (logic bug in selectWorkspaceAppHostPath loop control flow).
| const candidate = candidates.find(candidate => isSamePath(candidate.path, configuredPath)); | ||
| if (candidate) { | ||
| return candidate.path; | ||
| } | ||
|
|
||
| return configuredPath; | ||
| } | ||
|
|
||
| return candidates.length === 1 ? candidates[0].path : undefined; |
There was a problem hiding this comment.
Bug: Loop always exits on first iteration — The unconditional return configuredPath at the end of the loop body means the loop can never iterate past the first element. If there are multiple configured paths (e.g., nested aspire.config.json files in a monorepo) and the first one doesn't match any discovered candidate, subsequent paths are never checked.
If the intent is "configured paths always take priority regardless of discovery", the loop is misleading and equivalent to if (configuredPaths.length > 0) return configuredPaths[0].
If the intent is "prefer configured paths that match a discovered candidate, falling through to the single-candidate check otherwise", the return configuredPath should be removed so non-matching paths are skipped:
for (const configuredPath of configuredPaths) {
const candidate = candidates.find(candidate => isSamePath(candidate.path, configuredPath));
if (candidate) {
return candidate.path;
}
// non-matching configured path — try next
}There was a problem hiding this comment.
Fixed in 257c815: selectWorkspaceAppHostPath now continues through all configured paths and only falls back after the loop, with a regression test covering multiple config files where a later configured path matches a discovered candidate.
Validated with:
npm run compile-tests -- --pretty falsenpm run unit-test -- --grep "AppHost discovery"
Ensure workspace AppHost selection checks all configured paths before falling back to the single discovered candidate, and add a regression test for multiple config files.\n\nCo-authored-by: Copilot <[email protected]>
|
Re-running the failed jobs in the CI workflow for this pull request because 1 job was identified as retry-safe transient failures in the CI run attempt.
|
|
oops |
Co-authored-by: Copilot <[email protected]>
PR Testing ReportPR Information
CLI Version Verification
Changes Analyzed
Test Scenarios ExecutedScenario 1: File-based AppHost create, discover, start, describe, stopObjective: Verify the PR CLI can create a fresh file-based AppHost, discover it, start it in isolated mode, query state, and stop it cleanly. Evidence:
Scenario 2: Invalid AppHost path fails safelyObjective: Verify explicit invalid AppHost paths produce a non-zero result instead of selecting/running the wrong project. Evidence:
Scenario 3: AppHost discovery respects .gitignore unless --all is usedObjective: Validate project discovery behavior around ignored AppHost paths changed by the PR's locator work. Evidence:
Extension Test CoverageObjective: Verify the VS Code extension unit/integration test suite after the Windows CI failure fix. Evidence:
Non-blocking ObservationAn initial aspire-starter smoke attempt failed when the dogfood CLI used its bundled/private .NET SDK (10.0.201) to build the generated Blazor web project from a fresh checkout. A direct build with a newer local .NET 10 SDK succeeded, and this PR does not modify the C# starter template or private SDK selection. I replaced that broad starter smoke with the targeted file-based AppHost scenario above to cover the PR's AppHost launch/discovery behavior. Summary
Overall ResultPR VERIFIED |
Use the existing fake container runtime resolver in the pipeline unit test context so the built-in container runtime check doesn't depend on Docker availability on CI runners. Co-authored-by: Copilot <[email protected]>
Keep the fake container runtime service-provider lookup null-safe and explicit. Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
|
❓ CLI E2E Tests unknown — 107 passed, 0 failed, 2 unknown (commit View all recordings
📹 Recordings uploaded automatically from CI run #26535148153 |
|
/backport to release/13.4 |
|
Started backporting to |
|
Adam Ratzman (@adamint) backporting to git am output$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch
Applying: Fix VS Code AppHost launch path resolution
Applying: Use aspire ls for extension AppHost discovery
Using index info to reconstruct a base tree...
M extension/src/extension.ts
M extension/src/test/appHostDataRepository.test.ts
M extension/src/test/appHostTreeView.test.ts
M extension/src/utils/workspace.ts
M extension/src/views/AppHostDataRepository.ts
Falling back to patching base and 3-way merge...
Auto-merging extension/src/extension.ts
Auto-merging extension/src/test/appHostDataRepository.test.ts
CONFLICT (content): Merge conflict in extension/src/test/appHostDataRepository.test.ts
Auto-merging extension/src/test/appHostTreeView.test.ts
CONFLICT (content): Merge conflict in extension/src/test/appHostTreeView.test.ts
Auto-merging extension/src/utils/workspace.ts
CONFLICT (content): Merge conflict in extension/src/utils/workspace.ts
Auto-merging extension/src/views/AppHostDataRepository.ts
CONFLICT (content): Merge conflict in extension/src/views/AppHostDataRepository.ts
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0002 Use aspire ls for extension AppHost discovery
Error: The process '/usr/bin/git' failed with exit code 128 |
Update the VS Code extension page to explain how the extension resolves AppHost launch paths before invoking the Aspire CLI: - SDK-style C# AppHosts: source files (Program.cs) resolve to .csproj - Single-file C# AppHosts: launch from source path directly - TypeScript/JavaScript AppHosts: launch from source path Mentions that AppHost discovery uses 'aspire ls'. Documents microsoft/aspire#17408. Co-authored-by: Copilot <[email protected]>
|
Pull request created: #1104
|
|
📝 Documentation has been drafted in microsoft/aspire.dev#1104 targeting Updated Note This draft PR needs human review before merging. |
* Fix VS Code AppHost launch path resolution * Use aspire ls for extension AppHost discovery * Refresh AppHost discovery consumers on changes * Use CLI language ids for AppHost discovery * Handle AppHost discovery failures in editor commands * Add TypeScript AppHost launch discovery coverage * Harden AppHost discovery process handling * Honor configured AppHosts in discovery * Consolidate extension AppHost discovery * Fix workspace test path separators * Fix AppHost configured path selection Ensure workspace AppHost selection checks all configured paths before falling back to the single discovered candidate, and add a regression test for multiple config files.\n\nCo-authored-by: Copilot <[email protected]> * Keep extension-launched AppHost CLI alive Keep the Aspire CLI process alive after VS Code launches an AppHost so the CLI-owned backchannel remains available for the lifetime of the extension-managed debug session. Propagate extension backchannel startup failures instead of returning success. Also ignore generated .modules directories for polyglot AppHosts. * Update extension build and CLI debug logging * Address AppHost launch review feedback Keep extension-managed CLI runs alive only until the AppHost backchannel disconnects, align configured AppHost discovery UX with scanned candidates, restore dynamic debug fallbacks, and return no disposable for async workspace prompts. Restore Yarn 1 frozen install compatibility for extension CI and avoid the npx package-name/bin-name mismatch in localization export. * Address extension discovery review feedback * Stabilize pipeline unit tests without Docker Use the existing fake container runtime resolver in the pipeline unit test context so the built-in container runtime check doesn't depend on Docker availability on CI runners. * Use ordinal comparison in pipeline test provider Keep the fake container runtime service-provider lookup null-safe and explicit. * Revert pipeline test isolation changes --------- (cherry picked from commit 00eff9d) Co-authored-by: David Fowler <[email protected]> Co-authored-by: Copilot <[email protected]>
Description
This fixes VS Code AppHost launch path handling when users run or debug Aspire from source files instead of project files. Previously, starting an Aspire debug session from an SDK-style C# AppHost source file such as
Program.cscould pass that source path through to the Aspire CLI as--apphost <path>/Program.cs, which the CLI does not accept for SDK-style AppHosts.The extension now uses CLI-backed AppHost discovery as the source of truth for launch targets:
aspire ls --format jsondiscovers AppHost candidates for the workspace.aspire lsalso includes the AppHost configured inaspire.config.json, even when that AppHost lives outside the current working directory's normal discovery results..csprojresolve to that project file before launch.${workspaceFolder}/AppHost/Program.cscan resolve to the discovered AppHost project.User-facing usage
Users can still point an Aspire launch configuration at the AppHost project file:
{ "type": "aspire", "request": "launch", "program": "${workspaceFolder}/AppHost/AppHost.csproj" }If a user starts debugging while an SDK-style AppHost source file is active, or a launch configuration points at that source file, the extension resolves the launch target to the containing discovered AppHost project before invoking the CLI. Single-file AppHosts still launch directly from source:
TypeScript AppHosts discovered by the CLI continue to launch from the source file path:
Fixes # (issue)
Validation
npm run compile-tests -- --pretty falsenpm run unit-test -- --grep "AspireDebugConfigurationProvider"npm run unit-test -- --grep "TypeScript apphost|AspireEditorCommandProvider|AppHost discovery|AspireDebugConfigurationProvider"dotnet test --project tests/Aspire.Cli.Tests/Aspire.Cli.Tests.csproj --no-launch-profile -- --filter-class "*.LsCommandTests" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"cd tests/testproject && aspire ls --format jsonaspire.config.jsonpointing outside the working directory, thendotnet run --project src/Aspire.Cli/Aspire.Cli.csproj -- ls --format jsonverified the configured AppHost is included.aspire init --language typescript --suppress-agent-init --non-interactive, then ranaspire ls --format jsonand verified it returns theapphost.tscandidate withlanguage: "typescript/nodejs".git diff --checkChecklist
<remarks />and<code />elements on your triple slash comments?