dotnet / dotnet/AspNetCore.Docs

[Blazor] Document how to package a Blazor Web App as a .NET tool

Open
#36,546 1 comment 1 reaction 1 assignee Claimed by @guardrex View on GitHub
aspnet-core/svc Blazor blazor/subsvc doc-idea Pri2
Dominant language
C#
Stars
13.1k
Forks
24.6k
Avg merge
1d 2h
Merged PRs (30d)
109

Description

There's no documentation on how to package an ASP.NET Core Blazor Web App (with server interactivity) as a .NET tool that can be installed via `dotnet tool install`.

This is useful for CLI tools that need a local web UI (configuration dashboards, testing tools, etc).

I've created a complete sample demonstrating the approach:
https://github.com/javiercn/blazor-pack-as-tool-sample

Key concepts covered:
- Two-project architecture (tool host + Blazor web app)
- MSBuild targets to publish the web app into the NuGet package
- Launching the web app as a subprocess with environment variables
- Parent process monitoring to prevent orphaned web servers

The repo includes a step-by-step tutorial in `docs/TUTORIAL.md`.

@baronfel you might be interested in looking at this. I'm not sure if it can be simplified with the .NET 10.0 additions.

@danroth27 since we have had people asking for this across different fronts over the years, I want to put it on your radar.

@guardrex wait for @baronfel and @danroth27 input on where to put this in the docs, or if they don't provide input in 30 days, find the appropriate location yourself. This doc is not urgent, just leaving things queued up.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.