Skip to content

[docs] Document VS Code AppHost launch path resolution - #1104

Closed
aspire-repo-bot[bot] wants to merge 2 commits into
release/13.4from
docs/vscode-apphost-launch-path-17408-c5cd0d0f7a22d531
Closed

aspire-repo-bot[bot] wants to merge 2 commits into
release/13.4from
docs/vscode-apphost-launch-path-17408-c5cd0d0f7a22d531

Conversation

@aspire-repo-bot

Copy link
Copy Markdown
Contributor

Documents changes from microsoft/aspire#17408 by @davidfowl.

Targeting release/13.4 — the latest release branch on microsoft/aspire.dev — because release/13.5 (from the source PR milestone 13.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 --apphost on the CLI, which the CLI does not accept for SDK-style AppHosts. After this fix, the extension resolves such paths to the containing .csproj before 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:

  • Added a AppHost launch path resolution subsection under "Run, debug, and deploy" explaining how program values are resolved:
    • SDK-style C# AppHosts: Program.cs (or any source file in an AppHost project folder) resolves to the .csproj
    • Single-file C# AppHosts (#:sdk Aspire.AppHost.Sdk): launch from source path directly
    • TypeScript/JavaScript AppHosts: launch from source path
  • Added a tip showing explicit .csproj usage
  • Updated the introductory sentence to mention that AppHost discovery uses aspire ls

Files modified

  • src/frontend/src/content/docs/get-started/aspire-vscode-extension.mdx — updated existing page

Generated by PR Documentation Check for issue #17408 · ● 9.9M · ◷

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]>
@aspire-repo-bot aspire-repo-bot Bot added the docs-from-code Copilot initiated issue from dotnet/aspire repo label May 27, 2026
@IEvangelist
David Pine (IEvangelist) marked this pull request as ready for review May 27, 2026 21:47
Copilot AI review requested due to automatic review settings May 27, 2026 21:47

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.

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 program is resolved for SDK-style C# projects vs single-file C# vs TypeScript/JavaScript AppHosts.
  • Adds a tip showing how to explicitly target an AppHost .csproj in launch.json.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@IEvangelist David Pine (IEvangelist) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@IEvangelist
David Pine (IEvangelist) enabled auto-merge (squash) May 29, 2026 15:33
auto-merge was automatically disabled May 29, 2026 15:44

Pull request was closed

@davidfowl

Copy link
Copy Markdown
Contributor

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

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.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too much detail

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs-from-code Copilot initiated issue from dotnet/aspire repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants