Skip to content

Adopt PublishWithContainerFiles for frontend assets and remove esproj coupling#1171

Open
Copilot wants to merge 2 commits into
mainfrom
copilot/use-publishwithcontainerfiles
Open

Adopt PublishWithContainerFiles for frontend assets and remove esproj coupling#1171
Copilot wants to merge 2 commits into
mainfrom
copilot/use-publishwithcontainerfiles

Conversation

Copilot AI commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

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

    • Define the frontend once as a Vite resource and wire it into the StaticHost publish artifact:
    var frontend = builder.AddViteApp("frontend", "../../frontend")
        .WithPnpm();
    
    var staticHostWebsite = builder.AddProject<Projects.StaticHost>("aspiredev")
        .WithExternalHttpEndpoints();
    
    staticHostWebsite.PublishWithContainerFiles(frontend, "./wwwroot");
    • Keep local run-mode frontend endpoint behavior under IsRunMode using the same frontend resource.
  • Remove esproj dependencies

    • Removed ../../frontend/frontend.esproj ProjectReference from src/statichost/StaticHost/StaticHost.csproj.
    • Removed src/frontend/frontend.esproj from Aspire.Dev.slnx.
  • Resulting resource model

    • Publish-time frontend artifact flow is now explicit in AppHost (frontendaspiredev ./wwwroot) via PublishWithContainerFiles, aligning the solution with Aspire 13 container-files publishing.

Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>
Copilot AI changed the title [WIP] Use PublishWithContainerFiles and remove esproj reference Adopt PublishWithContainerFiles for frontend assets and remove esproj coupling Jun 2, 2026
Copilot AI requested a review from IEvangelist June 2, 2026 03:13
@IEvangelist IEvangelist marked this pull request as ready for review June 30, 2026 08:38
Copilot AI review requested due to automatic review settings June 30, 2026 08:38

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

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.cs and 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.esproj solution/project coupling (StaticHost ProjectReference and .slnx entry).

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 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 — 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:

  • staticHostWebsite is IResourceBuilder<ProjectResource>, and ProjectResource implements IContainerFilesDestinationResource, satisfying the where T : IContainerFilesDestinationResource constraint.
  • frontend is IResourceBuilder<ViteAppResource>; ViteAppResource : JavaScriptAppResource and JavaScriptAppResource : … IResourceWithContainerFiles. Because IResourceBuilder<out T> is covariant, it is assignable to the source parameter's IResourceBuilder<IResourceWithContainerFiles>.
  • "./wwwroot" binds to string 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 : IContainerFilesDestinationResourcesrc/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 : IResourceWithEndpointssrc/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.cs
  • Aspire.Dev.slnx
  • src/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).

@IEvangelist IEvangelist enabled auto-merge (squash) June 30, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use PublishWithContainerFiles and remove esproj reference

3 participants