Skip to content

Fix VS Code extension re-adding nonexistent configured AppHost path - #20112

Merged
Ella Hathaway (ellahathaway) merged 2 commits into
microsoft:mainfrom
SankeerthNara:VS-Code-extension-re-adds-nonexistent-AppHost-omitted-by-aspire-ls
Oct 12, 2026
Merged

Ella Hathaway (ellahathaway) merged 2 commits into
microsoft:mainfrom
SankeerthNara:VS-Code-extension-re-adds-nonexistent-AppHost-omitted-by-aspire-ls

Conversation

@SankeerthNara

@SankeerthNara Sankeerth Nara (SankeerthNara) commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes #20013

Prevent stale or mistyped configured paths from appearing as phantom, buildable AppHosts in VS Code. Candidate discovery and default selection are now separate: configuration can select a discovered AppHost, but cannot add one omitted by successful CLI discovery.

Discovery and selection

Successful aspire ls results are authoritative, including empty results and both buffered and streaming output. _selectConfiguredAppHostCandidate preserves CLI-provided selection, otherwise marks an existing candidate that matches configuration by filesystem identity. If no candidate matches, the returned list is unchanged.

For example, when ls returns aspire-apphost.csproj but configuration references the nonexistent aspire_apphost.csproj, only the real project remains in the extension's candidate list. An existing ordinary project also stays excluded if the CLI did not return it; checking file existence alone would not enforce this boundary.

Compatibility and file fallback

  • The legacy adapter preserves selected_project_file, including older responses where the selected project is absent from all_project_file_candidates. This is a CLI-declared selection, not a candidate inferred from configuration.
  • Only after both CLI discovery paths fail does file fallback inspect configured external .csproj, .fsproj, and .vbproj files alongside scanned projects. Both use the existing AppHost-content recognizer. Missing, directory, unreadable, unsupported, and non-AppHost targets are skipped without discarding useful candidates. This is content-based recognition, not a guarantee that MSBuild will succeed.
  • Exact resolved paths deduplicate reads; native filesystem identity merges candidate aliases. Distinct case-only paths remain separate in case-sensitive Windows directories.

No new dependencies or CLI output-contract changes are required.

Regression coverage

The tests exercise the discovery service and repository rather than only the selection helper:

Scenario Expected behavior
Stale configured path from the reported issue Keep the real CLI candidate; do not add the missing path.
Streaming, buffered, retry, and legacy discovery; populated and empty results Preserve the successful CLI candidate set even when the configured file exists.
Matching configured candidate and filesystem aliases Select the returned candidate without adding a duplicate.
Legacy enumerated, selected-only, and alias results Preserve the CLI's selection rather than overriding it from local configuration.
File fallback with valid and invalid configured targets Recognize supported external .NET AppHosts; skip invalid targets and retain useful candidates.
Equal and distinct case-only filesystem identities Merge aliases without dropping a distinct configured AppHost.

The real VS Code E2E regression writes a stale configured path, executes Refresh AppHosts, and asserts the complete candidate list, selected real AppHost, and absence of a discovery error. Editor-source and external-selection mocks now return the configured candidate from ls. The external fixture uses sibling workspace and external directories under one unique cleanup root.

Validation

TypeScript test compilation and targeted ESLint passed. The focused discovery/repository suites passed 249 tests, and the freshly packaged real VS Code discovery/configuration E2E shard passed 4 tests with 0 failures or pending tests. The prior fallback implementation failed both distinct-identity regressions while passing their equal-identity control; the corrected implementation passes all three.

These are targeted local results, not a claim that every PR CI job has completed.

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

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

Or

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

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

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.

The missing-file guard does not address the underlying re-insertion after aspire ls succeeds. Please fix that in the extension, preserve older-CLI fallback, update the tests, and isolate the external-AppHost fixture as noted in the three inline comments.

Comment thread extension/src/utils/appHostDiscovery.ts Resolved
Configuration selects a discovered AppHost without manufacturing candidates. Preserve legacy CLI selected_project_file metadata, including older selected-only results and filesystem aliases.

Validate configured external .NET projects through the existing file-fallback AppHost recognizer. Deduplicate aliases by native identity without dropping case-only paths in case-sensitive Windows directories. Log invalid or unreadable targets without discarding usable candidates, isolate external fixtures, and add focused and real VS Code regressions.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 2e79ae9e-900d-4085-951b-7c801db5ca68

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 implementation matches the reported behavior and includes comprehensive focused coverage.

0 open findings

What changed in this PR

Separates AppHost discovery from configuration-based selection, preventing stale configured paths from creating phantom AppHosts.

Changes:

  • Treats successful CLI discovery as authoritative.
  • Validates configured projects during file fallback and deduplicates filesystem aliases.
  • Adds unit, repository, and VS Code E2E regression coverage.
File Description
extension/​src/​utils/​appHostProjectFiles.ts Validates configured fallback projects.
extension/​src/​utils/​appHostDiscovery.ts Selects without manufacturing candidates.
extension/​src/​utils/​appHostCandidateParsing.ts Preserves legacy CLI selection.
extension/​src/​test/​appHostDiscovery.test.ts Covers discovery and fallback scenarios.
extension/​src/​test/​appHostDataRepository.test.ts Covers external configured candidates.
extension/​src/​test-e2e/​discoveryConfiguration.e2e.test.ts Adds stale-path E2E regression coverage.
extension/​CONTRIBUTING.md Documents discovery semantics.

🧠 Review effort: Balanced


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

@ellahathaway
Ella Hathaway (ellahathaway) merged commit 79544fa into microsoft:main Oct 12, 2026
93 checks passed
@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 17.0 milestone Oct 12, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VS Code extension re-adds nonexistent AppHost omitted by aspire ls

3 participants