Repository navigation
[docs] Document VS Code AppHost launch path resolution - #1104
aspire-repo-bot[bot] wants to merge 2 commits into
Conversation
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]>
There was a problem hiding this comment.
Pull request overview
Documents the VS Code extension’s updated AppHost launch path resolution behavior so users understand how program is interpreted (especially when starting debug from Program.cs) and how AppHosts are discovered.
Changes:
- Clarifies that AppHost discovery in the workspace uses
aspire ls. - Adds an “AppHost launch path resolution” section describing how
programis resolved for SDK-style C# projects vs single-file C# vs TypeScript/JavaScript AppHosts. - Adds a tip showing how to explicitly target an AppHost
.csprojinlaunch.json.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
David Pine (IEvangelist)
left a comment
There was a problem hiding this comment.
Docs accuracy review
Source of truth: microsoft/aspire@cc4b7eaf (release/13.4, fetched 2026-05-29)
PR head: 3cb72e424720571223a0e73f696e1a98d5e5f767
| Verdict | Count |
|---|---|
| verified | 5 |
| verified-with-nuance | 0 |
| unverifiable | 0 |
| contradicted | 0 |
Verdict: APPROVE. Each of the three AppHost-launch resolution rules matches the extension's behavior at release/13.4, and the aspire ls-based discovery story is exact.
Doc-tester (UX) notes
The three bullet points map cleanly onto the test scenarios shipped with the extension (aspireDebugConfigurationProvider.test.ts has named cases for each of the three: Program.cs → .csproj, single-file apphost.cs unchanged, apphost.ts unchanged). A user copying the JSON snippet that targets .csproj directly will succeed because the resolver leaves an already-.csproj program unchanged.
Verified claims (with evidence)
| # | Claim | Evidence |
|---|---|---|
| 1 | "AppHosts are discovered automatically in the workspace using aspire ls." |
extension/src/utils/appHostDiscovery.ts:118 "Discovered ${appHosts.length} AppHost candidate(s) via aspire ls"; :146 parseCandidateOutput(output, 'aspire ls'); :329-336 explicit "IMPORTANT: aspire ls is still the source of truth for what is a valid AppHost." |
| 2 | "The extension resolves the program path to the correct launch target before invoking the CLI." |
extension/src/debugger/AspireDebugConfigurationProvider.ts:66-72 resolveDebugConfigurationWithSubstitutedVariables calls _appHostDiscoveryService.resolveDebugTarget(config.program, folder) and writes the result back to config.program before VS Code hands the session off. |
| 3 | "SDK-style C# AppHosts — If program points to a C# source file ... inside an AppHost project folder, the extension automatically resolves that path to the containing .csproj file." |
extension/src/utils/appHostDiscovery.ts:320-351 — when filePath is .cs and not itself a candidate, the resolver picks the deepest C# .csproj candidate from aspire ls whose directory contains the file (isCSharpSourceFileForProjectCandidate). Asserted by extension/src/test/aspireDebugConfigurationProvider.test.ts assert.strictEqual(config?.program, projectPath) for the Program.cs → .csproj case. |
| 4 | "Single-file C# AppHosts — Files with the #:sdk Aspire.AppHost.Sdk directive ... launch directly from their source path, not from a project file." |
appHostDiscovery.ts:353-355 getDebugTargetForCandidate(candidate) returns candidate.path unchanged for single-file candidates returned by aspire ls. Test aspireDebugConfigurationProvider.test.ts:46-59 "leaves launch config single-file apphost.cs unchanged" writes a #:sdk Aspire.AppHost.Sdk file and asserts config.program === appHostPath. The #:sdk Aspire.AppHost.Sdk directive detection lives in extension/src/editor/parsers/csharpAppHostParser.ts:138. |
| 5 | "TypeScript/JavaScript AppHosts — Files discovered by aspire ls as language: \"typescript/nodejs\" (for example, apphost.ts) continue to launch from their source file path." |
The CLI's KnownLanguageId.TypeScript = "typescript/nodejs" (src/Aspire.Cli/Projects/KnownLanguageId.cs:25) is what surfaces in aspire ls output, recognized by the extension at appHostDiscovery.ts:387-388. Same getDebugTargetForCandidate returns the source path; test aspireDebugConfigurationProvider.test.ts:61-74 "leaves launch config TypeScript apphost.ts unchanged" asserts the source apphost.ts path is preserved. |
Co-authored-by: David Pine <[email protected]>
Pull request was closed
|
This doesn't need to be documented. |
| ## Run, debug, and deploy | ||
|
|
||
| **Aspire: Configure launch.json file** adds a minimal launch configuration `.vscode/launch.json` that supports AppHosts written in any language. AppHosts are discovered automatically in the workspace. | ||
| **Aspire: Configure launch.json file** adds a minimal launch configuration `.vscode/launch.json` that supports AppHosts written in any language. AppHosts are discovered automatically in the workspace using `aspire ls`. |
There was a problem hiding this comment.
I'm not sure this is an important detail.
|
|
||
| - **SDK-style C# AppHosts** — If `program` points to a C# source file (for example `Program.cs`) inside an AppHost project folder, the extension automatically resolves that path to the containing `.csproj` file. This means starting a debug session from an open `Program.cs` in VS Code works without extra configuration. | ||
| - **File-based C# AppHosts** — Files with the `#:sdk Aspire.AppHost.Sdk` directive at the top are standalone scripts and launch directly from their source path, not from a project file. | ||
| - **TypeScript/JavaScript AppHosts** — Files discovered by `aspire ls` as `language: "typescript/nodejs"` (for example, `apphost.ts`) continue to launch from their source file path. |
Documents changes from microsoft/aspire#17408 by
@davidfowl.Targeting
release/13.4— the latest release branch onmicrosoft/aspire.dev— becauserelease/13.5(from the source PR milestone13.5) does not exist there.Why this PR is needed
microsoft/aspire#17408 fixed how the VS Code extension resolves AppHost launch paths when a user starts debugging from an SDK-style C# AppHost source file (
Program.cs) rather than from a project file. Previously, the source file path could be passed to--apphoston the CLI, which the CLI does not accept for SDK-style AppHosts. After this fix, the extension resolves such paths to the containing.csprojbefore invoking the CLI.This user-facing behavior change — including the three-way resolution rule for C# project-based, single-file C# and TypeScript AppHosts — was not documented on the VS Code extension page.
What changed
Updated
src/frontend/src/content/docs/get-started/aspire-vscode-extension.mdx:programvalues are resolved:Program.cs(or any source file in an AppHost project folder) resolves to the.csproj#:sdk Aspire.AppHost.Sdk): launch from source path directly.csprojusageaspire lsFiles modified
src/frontend/src/content/docs/get-started/aspire-vscode-extension.mdx— updated existing page