Skip to content

Creating Blazor Gateway CLI package and tests#67599

Open
javiercn with Copilot wants to merge 4 commits into
mainfrom
copilot/create-blazor-gateway-cli
Open

Creating Blazor Gateway CLI package and tests#67599
javiercn with Copilot wants to merge 4 commits into
mainfrom
copilot/create-blazor-gateway-cli

Conversation

Copilot AI commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Pull request created by AI Agent

<PackageId>Microsoft.AspNetCore.Components.Gateway.Cli</PackageId>
<IsShippingPackage>true</IsShippingPackage>
<IsPackable>true</IsPackable>
<Description>Command line tool (blazor-gateway) for hosting standalone Blazor WebAssembly applications. Packs the Microsoft.AspNetCore.Components.Gateway binaries as a .NET tool.</Description>

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.

@copilot The Blazor gateway is an optimized host for Blazor applications in general, not just for werbassembly. fix the description. No need to put the packs xxx as a tool

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 6c1c8b1: description now reads "Command line tool (blazor-gateway) for hosting Blazor applications." (also updated the Gateway package's own description and dropped the webassembly package tag) and removed the "packs as a .NET tool" wording.

Copilot AI requested a review from javiercn July 4, 2026 07:02
@javiercn javiercn marked this pull request as ready for review July 6, 2026 12:50
@javiercn javiercn requested a review from a team as a code owner July 6, 2026 12:50
Copilot AI review requested due to automatic review settings July 6, 2026 12:50
Copilot AI and others added 4 commits July 6, 2026 14:50
Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
…n package tests

Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
…ot just WebAssembly

Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
@javiercn javiercn force-pushed the copilot/create-blazor-gateway-cli branch from df39cac to f6c061a Compare July 6, 2026 12:50

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

Adds a new Blazor Gateway dotnet-tool package (CLI) and introduces packaging + end-to-end installation tests to validate the produced tool can be installed and run. It also updates the Blazor WASM template test infrastructure to serve published standalone output using blazor-gateway instead of dotnet serve.

Changes:

  • Adds Microsoft.AspNetCore.Components.Gateway.Cli packaging project (nuspec + tool settings) that repackages the Gateway publish output as a dotnet tool.
  • Adds Gateway CLI package/installation tests plus supporting test infrastructure to locate locally-built packages and run the installed tool.
  • Updates template test hosting to launch blazor-gateway against published output and derive the listening URL.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/ProjectTemplates/Shared/Project.cs Switches standalone published template hosting from dotnet serve to blazor-gateway, and adds gateway DLL resolution logic.
src/Components/Gateway/test/RequiresBuiltGatewayCliPackageAttribute.cs Adds a conditional test gate that skips CLI packaging tests when local .nupkg outputs aren’t available.
src/Components/Gateway/test/Microsoft.AspNetCore.Components.Gateway.Tests.csproj Injects assembly metadata needed by CLI packaging tests to locate artifacts and repo paths.
src/Components/Gateway/test/GatewayToolInstallation.cs Adds helper to install the locally-built CLI package as a dotnet tool and start it for tests.
src/Components/Gateway/test/GatewayCliTestData.cs Centralizes access to test-time metadata (package dirs/version, repo paths, dotnet host paths).
src/Components/Gateway/test/BlazorGatewayCliToolTests.cs Adds end-to-end tests ensuring the installed tool command exists and serves requests.
src/Components/Gateway/test/BlazorGatewayCliPackageTests.cs Validates dotnet-tool package structure/content by inspecting the installed tool layout.
src/Components/Gateway/src/Microsoft.AspNetCore.Components.Gateway.csproj Updates package description text.
src/Components/Gateway/cli/Microsoft.AspNetCore.Components.Gateway.Cli.nuspec Introduces nuspec defining dotnet-tool package type and file layout for the CLI.
src/Components/Gateway/cli/Microsoft.AspNetCore.Components.Gateway.Cli.csproj Adds packaging project that publishes Gateway and packs it as a dotnet tool.
src/Components/Gateway/cli/DotnetToolSettings.xml Defines the blazor-gateway tool command entrypoint mapping.
AspNetCore.slnx Adds the Gateway (src/cli/test) projects to the solution.

Comment on lines +294 to +297
var packageRoot = Environment.GetEnvironmentVariable("NUGET_PACKAGES")
?? typeof(Project).Assembly.GetCustomAttributes<AssemblyMetadataAttribute>()
.FirstOrDefault(attribute => attribute.Key == "TestPackageRestorePath")?.Value
?? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".nuget", "packages");
Comment on lines +304 to +306
var matchingVersion = Directory.EnumerateDirectories(gatewayPackageRoot)
.OrderByDescending(Path.GetFileName)
.FirstOrDefault();
Comment on lines +176 to +184
var completed = await Task.WhenAny(listeningUrl.Task, Task.Delay(TimeSpan.FromSeconds(60)));
if (completed != listeningUrl.Task)
{
try { process.Kill(entireProcessTree: true); } catch { }
process.Dispose();
throw new TimeoutException($"The gateway tool did not start listening within the timeout.\n{log}");
}

return new RunningGatewayTool(process, await listeningUrl.Task, log);
Comment on lines 262 to 263
var listeningUri = ResolveListeningUrl(serveProcess);
return (serveProcess, listeningUri);
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.

3 participants