Repository navigation
Replace removed AddNpmApp in the What is Aspire C# AppHost sample - #1998
Merged
David Pine (IEvangelist) merged 1 commit intoOct 30, 2026
Merged
Conversation
AddNpmApp was removed in Aspire 13 (see whats-new/aspire-13). The C# tab on get-started/what-is-aspire still called it, so the copied sample does not compile against current Aspire.Hosting.JavaScript. Use AddViteApp, matching the TypeScript tab's addViteApp, and add a unit check that get-started C# AppHost samples only call builder Add* APIs present in the generated package API data. Co-authored-by: Copilot <[email protected]>
Contributor
Frontend HTML artifact readyThe latest frontend build uploaded the This comment updates automatically when a new frontend build artifact is uploaded. |
David Fowler (davidfowl)
marked this pull request as ready for review
October 30, 2026 15:35
David Fowler (davidfowl)
requested a review
from David Pine (IEvangelist)
as a code owner
October 30, 2026 15:35
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the sample API update and accompanying regression test.
No open issues 🎉
What changed in this PR
Updates the introductory C# AppHost sample to use AddViteApp instead of the removed AddNpmApp, matching the sibling TypeScript example.
Changes:
- Replaces the obsolete API call in “What is Aspire?”
- Adds a regression test that checks
builder.AddXxxcalls in get-started C# AppHost samples against generated package API member names.
| File | Description |
|---|---|
src/frontend/tests/unit/get-started-apphost-apis.vitest.test.ts |
Adds API-name validation for get-started C# AppHost samples. |
src/frontend/src/content/docs/get-started/what-is-aspire.mdx |
Switches the frontend resource to AddViteApp. |
Review effort: Balanced
David Pine (IEvangelist)
enabled auto-merge (squash)
October 30, 2026 15:43
David Pine (IEvangelist)
approved these changes
Oct 30, 2026
David Pine (IEvangelist)
deleted the
aspireagent/fix-what-is-aspire-addnpmapp
branch
October 30, 2026 15:44
David Pine (IEvangelist)
pushed a commit
that referenced
this pull request
Nov 3, 2026
…2004) ## Summary This PR started as a fix for the Japanese [What is Aspire?](https://aspire.dev/ja/get-started/what-is-aspire/) C# AppHost sample, which called `AddNpmApp`. That API was removed in Aspire 13. #2015 has since replaced the line on `main` with `AddJavaScriptApp("frontend", "../frontend")`. After the rebase, this PR keeps `main`'s line and is **test-only**. **Change:** extend the regression test that #1998 added, `tests/unit/get-started-apphost-apis.vitest.test.ts`. - It now scans `get-started/` in every locale, not just English. - It asserts that at least one localized `get-started` directory was included, so the coverage can't silently drop. - It normalizes path separators so the reported paths are stable on Windows. Without this change, a localized sample that calls an API missing from the published `src/data/pkgs` data, like `AddNpmApp`, isn't caught. Maintainers can close this PR if they don't want the extra guard. ## Third-party links and affiliations None. ## Validation - `npx vitest run tests/unit/get-started-apphost-apis.vitest.test.ts` passes on the rebased head. - Negative check: temporarily restoring `AddNpmApp` in `ja/get-started/what-is-aspire.mdx` makes the test fail with that entry. I then reverted the probe. No screenshots, because this PR has no rendered changes. **🤖 Posted by AspireAgent (AI Agent)** --------- Co-authored-by: davidfowl <[email protected]> Co-authored-by: Copilot <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The C# tab of the flagship What is Aspire? AppHost sample calls
builder.AddNpmApp("frontend", "../frontend").AddNpmAppwas removed in Aspire 13 (this repo's ownwhats-new/aspire-13.mdxsays: "AddNpmApp()- UseAddJavaScriptApp()instead … orAddViteApp()for Vite projects"), so a reader who copies the sample into a file-based AppHost referencing the currentAspire.Hosting.JavaScriptgets a compile error.Fix: use
AddViteApp("frontend", "../frontend"), which matches the sibling TypeScript tab (addViteApp("frontend", "../frontend")) and the current API:JavaScriptHostingExtensions.AddViteApp(this IDistributedApplicationBuilder builder, string name, string appDirectory, string runScriptName = "dev")insrc/data/pkgs/Aspire.Hosting.JavaScript.13.6.0.json, generated from microsoft/aspiresourceCommitf4c27f2d43ddc1cacd0dd083b30d1fea1cee7a62. That API data contains noAddNpmAppmember.Regression check: the new
tests/unit/get-started-apphost-apis.vitest.test.tsreads every C# fence underget-started/that containsDistributedApplication.CreateBuilder. It asserts that eachbuilder.AddXxx(call exists as a member in the generatedsrc/data/pkgsAPI data.["src/content/docs/get-started/what-is-aspire.mdx: AddNpmApp"].How this was found: I audited English docs C# samples against the in-repo generated package API data (5,004 member names, 202 packages). Across 1,675
builder.AddXxx(calls in AppHost fences (excludingwhats-new, which is historical), the only call missing from upstream data wasAddNpmApp. The other misses are tutorial-defined extensions such asAddMailDevandAddMyResource.AddNpmAppalso appears inapp-host/certificate-configuration.mdx,architecture/resource-hierarchies.mdxandarchitecture/resource-model.mdx. I deliberately left those files alone because open PRs #1636, #1634 and #1164 touch them, so the new test is scoped toget-started/.Rendered C# tab, desktop 1280×900, light theme (local dev server)
Third-party links and affiliations
None
Validation
npx vitest run tests/unit/get-started-apphost-apis.vitest.test.ts: fails onmain(theAddNpmAppentry above) and passes with the fix.npx vitest run: 84 files, 1,120 passed, 1 skipped.npx eslint . --max-warnings 0: clean.npx prettier --checkon the new test: clean.what-is-aspire.mdxalready has Prettier warnings onmain; this change doesn't touch them.astro devserver.🤖 Posted by AspireAgent (AI Agent)