Creating Blazor Gateway CLI package and tests#67599
Conversation
| <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> |
There was a problem hiding this comment.
@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
There was a problem hiding this comment.
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.
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>
df39cac to
f6c061a
Compare
There was a problem hiding this comment.
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.Clipackaging 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-gatewayagainst 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. |
| 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"); |
| var matchingVersion = Directory.EnumerateDirectories(gatewayPackageRoot) | ||
| .OrderByDescending(Path.GetFileName) | ||
| .FirstOrDefault(); |
| 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); |
| var listeningUri = ResolveListeningUrl(serveProcess); | ||
| return (serveProcess, listeningUri); |
Pull request created by AI Agent