Skip to content

Use Blazor gateway CLI during development - #19432

Open
Javier Calvarro Nelson (javiercn) wants to merge 3 commits into
microsoft:mainfrom
javiercn:javiercn-blazor-cli-development
Open

Use Blazor gateway CLI during development#19432
Javier Calvarro Nelson (javiercn) wants to merge 3 commits into
microsoft:mainfrom
javiercn:javiercn-blazor-cli-development

Conversation

@javiercn

@javiercn Javier Calvarro Nelson (javiercn) commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Description

Standalone Blazor WebAssembly apps now use the official Blazor Gateway CLI during local development instead of launching Aspire's generated file-based gateway. This keeps development aligned with the ASP.NET Core gateway implementation while preserving the existing AddBlazorGateway API, project resource/dashboard experience, endpoints, certificates, telemetry, and client resource relationships.

The run-mode project resource is launched as a process through:

dotnet tool exec Microsoft.AspNetCore.Components.Gateway.Cli --version 11.0.0-preview.7.26381.103 --yes -- ...

The CLI version is centrally pinned and requires the .NET 11 Preview 7 SDK or later. Publish behavior intentionally retains the generated Gateway.cs and its existing SDK 10 runtime image.

The standalone WASM client now targets .NET 11 Preview 7 and enables the SDK's canonical SPA fallback contract:

<TargetFramework>net11.0</TargetFramework>
<StaticWebAssetSpaFallbackEnabled>true</StaticWebAssetSpaFallbackEnabled>

Aspire removes SDK-generated or legacy fallback endpoints before adding one path-prefixed identity fallback using the canonical {**fallback:nonfile} route and string Order="2147483647". The same transformation is used during publish. Existing net10 clients retain the SDK 10 publish image, while net11 clients use the Preview 7 SDK image.

The built-in gateway also suppresses the obsolete Gateway.cs source display while retaining its ProjectResource model shape.

User-facing usage

The existing C# API is unchanged:

var blazorApp = builder.AddBlazorWasmApp("app", "../Blazor/Blazor.csproj");

builder.AddBlazorGateway("gateway")
    .WithBlazorClientApp(blazorApp);

Validation

  • All 82 Aspire.Hosting.Blazor.Tests passed.
  • All 8 ResourceSourceViewModel dashboard model cases passed.
  • SDK 10 AppHost restore/build succeeds without warnings or errors.
  • SDK 11 Preview 7 client restore/build succeeds without warnings or errors.
  • The SDK-generated manifest contains identity and compressed {**fallback:nonfile} endpoints with string order.
  • Aspire's transformed development and publish manifests contain exactly one prefixed identity fallback with no content-encoding selector.
  • Playwright validates configuration JSON, weather/time service discovery, OTLP proxying, rendered UI, no browser console errors, and dashboard source suppression.
  • A live run uses an SDK 10 AppHost/services with the project-scoped SDK 11 client and gateway CLI.

Fixes # (issue)

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

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings August 17, 2026 10:25
@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 -- 19432

Or

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

@github-actions github-actions Bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Aug 17, 2026

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

Moves run-mode Blazor gateways to the official CLI while retaining the generated gateway for publishing.

Changes:

  • Configures dotnet tool exec with SDK validation.
  • Preserves project-resource behavior and publish output.
  • Adds tests, dependency metadata, and sample documentation.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/Aspire.Hosting.Blazor.Tests/AddBlazorGatewayTests.cs Tests run and publish behavior.
src/Aspire.Hosting.Blazor/BlazorGatewayExtensions.cs Launches the CLI during development.
src/Aspire.Hosting.Blazor/Aspire.Hosting.Blazor.csproj Stamps the CLI version.
playground/BlazorStandalone/README.md Documents CLI-based development.
playground/BlazorStandalone/BlazorStandalone.AppHost/BlazorStandalone.AppHost.csproj Adds the Dotnet hosting reference.
eng/Versions.props Pins the CLI package version.
eng/Version.Details.xml Records dependency provenance.

Comment on lines +101 to +105
Assert.Contains("FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build", dockerfile);
Assert.Contains("COPY Gateway.cs .", dockerfile);
Assert.Contains("RUN dotnet publish Gateway.cs -c Release -o /app/publish", dockerfile);
Assert.Contains("FROM mcr.microsoft.com/dotnet/aspnet:10.0", dockerfile);
Assert.Contains("COPY --from=build /app/publish .", dockerfile);
Command = "dotnet",
WorkingDirectory = builder.AppHostDirectory
})
.WithAnnotation(new ProjectLaunchArgsOverrideAnnotation(["run"]))
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 17, 2026 11:25
@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.

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

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Suppressed comments (1)

src/Aspire.Hosting.Blazor/BlazorGatewayExtensions.cs:37

  • The public API documentation omits the new run-mode prerequisite. Callers relying on IntelliSense will only learn that AddBlazorGateway now requires .NET 11 Preview 7 after validation fails; document the minimum SDK here as well as in the playground README.
    /// During development the gateway runs from the official .NET tool. The file-based app
    /// shipped with this package remains the publish implementation.

Comment on lines +63 to +64
Command = "dotnet",
WorkingDirectory = builder.AppHostDirectory
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 17, 2026 13:29

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Note

This error may be related to your runner configuration. You can now configure runners for Copilot code review separately from Copilot cloud agent by creating a copilot-code-review.yml file with your setup steps. Read the docs for details.

@adamint

Copy link
Copy Markdown
Member

does this break aspire runs in vs code?

@javiercn

Copy link
Copy Markdown
Contributor Author

does this break aspire runs in vs code?

Have not explicitly tried VS Code, but how would it break it? (Dashboard works fine)

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

Labels

needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants