Adopt PublishWithContainerFiles for frontend assets and remove esproj coupling#1171
Adopt PublishWithContainerFiles for frontend assets and remove esproj coupling#1171Copilot wants to merge 2 commits into
PublishWithContainerFiles for frontend assets and remove esproj coupling#1171Conversation
Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>
PublishWithContainerFiles for frontend assets and remove esproj coupling
There was a problem hiding this comment.
Pull request overview
This PR updates the Aspire AppHost to model frontend build output as an explicit resource relationship at publish time, using Aspire 13 container file injection (PublishWithContainerFiles) instead of coupling the StaticHost project to a frontend.esproj MSBuild reference.
Changes:
- Define the Vite frontend once in
AppHost.csand reuse it for both publish-time asset injection and local run-mode endpoints. - Wire frontend build artifacts into the StaticHost publish output via
PublishWithContainerFiles(frontend, "./wwwroot"). - Remove the
frontend.esprojsolution/project coupling (StaticHostProjectReferenceand.slnxentry).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/statichost/StaticHost/StaticHost.csproj | Removes frontend.esproj ProjectReference now that frontend assets are supplied via AppHost publish wiring. |
| src/apphost/Aspire.Dev.AppHost/AppHost.cs | Introduces a shared Vite resource and injects its build output into StaticHost during publish using PublishWithContainerFiles. |
| Aspire.Dev.slnx | Removes the src/frontend/frontend.esproj entry from the solution. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
IEvangelist
left a comment
There was a problem hiding this comment.
Docs-accuracy review — PR #1171
Source of truth (Phase A): microsoft/aspire @ release/13.3 (SHA 386b6fc0cdaff8024f53f4a87e4586b9bf44581b) — chosen because aspire.dev main pins Aspire.AppHost.Sdk/13.3.0 and the Aspire.Hosting.* packages at 13.3.0 in src/apphost/Aspire.Dev.AppHost/Aspire.Dev.AppHost.csproj. All Vite/pnpm APIs in this PR live in the core Aspire.Hosting.JavaScript package (not the Community Toolkit), so no CommunityToolkit/Aspire or Azure/azure-sdk-for-net lookups were required.
Claims extracted: 6 non-narrative API claims — 6 verified, 0 verified-with-nuance, 0 unverifiable, 0 contradicted.
Phase B (doc-tester): No documentation routes in scope — the diff touches only AppHost publish wiring and solution/project files; 0 critical, 0 warnings. Details below.
Verdict: APPROVE.
Phase A — Claim verification
This PR is an infrastructure change to the site's own AppHost rather than documentation prose, so the verifiable "claims about Aspire" are the API usages added in AppHost.cs (and mirrored in the PR description). Every one matches the public API surface on release/13.3. No contradicted or unverifiable claims, so there are no blocking inline comments.
The crux is the new PublishWithContainerFiles(frontend, "./wwwroot") call. It compiles exactly as written:
staticHostWebsiteisIResourceBuilder<ProjectResource>, andProjectResourceimplementsIContainerFilesDestinationResource, satisfying thewhere T : IContainerFilesDestinationResourceconstraint.frontendisIResourceBuilder<ViteAppResource>;ViteAppResource : JavaScriptAppResourceandJavaScriptAppResource : … IResourceWithContainerFiles. BecauseIResourceBuilder<out T>is covariant, it is assignable to thesourceparameter'sIResourceBuilder<IResourceWithContainerFiles>."./wwwroot"binds tostring destinationPath.
Verified claims with evidence (6)
| # | Claim (raw) | Verdict | Evidence (microsoft/aspire @ release/13.3) |
|---|---|---|---|
| 1 | builder.AddViteApp("frontend", "../../frontend") |
verified | AddViteApp(this IDistributedApplicationBuilder, string name, string appDirectory, string runScriptName = "dev") — src/Aspire.Hosting.JavaScript/api/Aspire.Hosting.JavaScript.cs:24 (two positional args; runScriptName defaults to "dev") |
| 2 | .WithPnpm() |
verified | WithPnpm<TResource>(this IResourceBuilder<TResource>, bool install = true, string[]? installArgs = null) where TResource : JavaScriptAppResource — …/Aspire.Hosting.JavaScript.cs:68; constraint met via ViteAppResource : JavaScriptAppResource (…/Aspire.Hosting.JavaScript.cs:177) |
| 3 | staticHostWebsite.PublishWithContainerFiles(frontend, "./wwwroot") |
verified | PublishWithContainerFiles<T>(this IResourceBuilder<T> builder, IResourceBuilder<IResourceWithContainerFiles> source, string destinationPath) where T : IContainerFilesDestinationResource — src/Aspire.Hosting/api/Aspire.Hosting.cs:1071. Supporting: ProjectResource : … IContainerFilesDestinationResource (Aspire.Hosting.cs:3242); JavaScriptAppResource : … IResourceWithContainerFiles (Aspire.Hosting.JavaScript.cs:91); IResourceBuilder<out T> covariance (Aspire.Hosting.cs:2893); IContainerFilesDestinationResource : IResource (Aspire.Hosting.cs:2764) |
| 4 | .WithExternalHttpEndpoints() (on the project and the Vite resource) |
verified | WithExternalHttpEndpoints<T>(this IResourceBuilder<T>) where T : IResourceWithEndpoints — src/Aspire.Hosting/api/Aspire.Hosting.cs:1237; both ProjectResource and JavaScriptAppResource implement IResourceWithEndpoints |
| 5 | frontend.WithUrlForEndpoint("http", static url => url.DisplayText = "aspire.dev (Local)") |
verified | WithUrlForEndpoint<T>(this IResourceBuilder<T>, string endpointName, System.Action<ResourceUrlAnnotation> callback) — src/Aspire.Hosting/api/Aspire.Hosting.cs:1403 (the lambda mutates ResourceUrlAnnotation.DisplayText, matching the Action<ResourceUrlAnnotation> overload) |
| 6 | builder.ExecutionContext.IsRunMode (context) |
verified | bool IsRunMode { get; } — src/Aspire.Hosting/api/Aspire.Hosting.cs:419 |
The Aspire.Dev.slnx and StaticHost.csproj edits are removals (dropping the frontend.esproj ProjectReference/solution entry and its explanatory comment), so they make no new assertions about Aspire to verify. Conceptually they are consistent with claim #3: the publish-time wwwroot flow now comes from PublishWithContainerFiles instead of the esproj MSBuild reference.
Phase B — Doc-tester results
Pages exercised: none (see scoping below). Critical issues: 0. Warnings: 0.
Scoping outcome (documented reason — complete, not partial): Phase B derives the doc routes to test from the PR's changed files. This PR changes only:
src/apphost/Aspire.Dev.AppHost/AppHost.csAspire.Dev.slnxsrc/statichost/StaticHost/StaticHost.csproj
None of these are documentation content (src/frontend/src/content/docs/**), and none alter the Astro frontend that the local pnpm dev server renders. The doc-tester's only window into behavior is the rendered site, and this PR's change is a publish-time AppHost wiring change (PublishWithContainerFiles injects the built frontend into the StaticHost container's ./wwwroot at publish, replacing the prior esproj build-time coupling). It does not run in the pnpm dev path, so the rendered pages a "blind" new user would see are byte-identical with and without this PR. There are therefore no in-scope documentation routes to validate, and no content for the tester to flag. Verifying the actual publish/container output is a build-and-deploy concern owned by CI and out of scope for this review.
Reviewed automatically by the doc-pr-reviewer skill (Phase A: source-of-truth claim verification; Phase B: doc-tester).
This updates the Aspire AppHost to use Aspire 13 publish-time container file injection for frontend assets, replacing the previous
esproj-based coupling. The frontend build output is now modeled as an AppHost resource relationship instead of an MSBuild project reference.AppHost publish wiring
IsRunModeusing the samefrontendresource.Remove
esprojdependencies../../frontend/frontend.esprojProjectReferencefromsrc/statichost/StaticHost/StaticHost.csproj.src/frontend/frontend.esprojfromAspire.Dev.slnx.Resulting resource model
frontend➜aspiredev./wwwroot) viaPublishWithContainerFiles, aligning the solution with Aspire 13 container-files publishing.