dotnet / dotnet/aspnetcore

[Validation] Enabling container support when creating a Blazor Web App

Open
#68,543 1 comment 0 reactions 1 assignee Claimed by @BharatRamsf3693 View on GitHub
area-blazor Validation validation-scenario
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 5h
Merged PRs (30d)
276

Description

**Scenario contact:** @javiercn

## Scenario

Other ASP.NET Core templates have long offered **Enable container support** in the project creation dialog. The Blazor Web App template did not, so teams deploying to containers had to add a Dockerfile by hand. In .NET 11 the IDE can generate Docker support for the Blazor Web App template too. What needs validating is that the Dockerfile the IDE produces builds and runs the app correctly.

That matters most for the **two-project shapes**. Interactive WebAssembly and Interactive Auto generate a server project plus a `.Client` project, and a Dockerfile has to get the build context and project references right for both. Blazor Web App is the first template offering this option that has that shape.

## Minimum build

.NET 11 Preview 7 or later.

## Configurations to cover

* Blazor Web App
* [x] Static SSR
* [x] Interactive Server
* [x] Interactive WebAssembly
* [x] Interactive Auto
* [ ] Standalone WebAssembly
* [ ] Hybrid (MAUI)

All four are ticked because the project layout differs between them, and the layout is what the Dockerfile has to cope with. The first two produce one project, the last two produce two.

## Also exercise

* [x] Published output
* [ ] An existing .NET 10 app upgraded to .NET 11
* [ ] Trimming or ahead-of-time compilation
* [ ] More than one server instance, or a proxy in front
* [ ] Hot Reload
* [ ] An IDE as well as the command line
* [x] Container

## Setup

Visual Studio with the container tooling installed, and a working container runtime.

This option exists only in the IDE project creation dialog. `dotnet new blazor` has no equivalent switch, so this scenario cannot be driven from the command line. If you cannot find the option, that is itself the finding.

## What to build

Create a Blazor Web App four times from the project creation dialog, once per interactivity choice, ticking **Enable container support** each time. Keep the sample content so there is something to click through.

To each app, add one page that loads an image and a stylesheet from the app's own `wwwroot`, so a missing static asset in the image is visible rather than silent.

## Things to try

* Finding the container option in the creation dialog for the Blazor Web App template.
* Building and running each of the four apps in a container immediately after creation, changing nothing.
* Clicking through the sample pages in the container, including the interactive ones, and loading your static-asset page.
* Reading the generated Dockerfile for the two-project shapes, checking how the `.Client` project is restored and copied.
* Running the same project outside a container.
* Publishing an image and running it outside the IDE.
* Creating the app with the option switched off, then adding container support from the project context menu afterwards, and comparing the result.

## Expected behavior

The option is offered, and the app it produces runs in a container without hand-editing.

### Must hold

* The creation dialog offers **Enable container support** for the Blazor Web App template, in the same place as for other ASP.NET Core templates.
* All four apps build a container image and run in it with no manual edits to the Dockerfile or the project files.
* In the container, every sample page works, interactivity starts, and the image and stylesheet on your own page load with no 404 in the browser network log.
* The two-project shapes behave the same as the single-project ones, with the `.Client` project's assets present in the image.
* The same projects still build and run outside a container.
* A published image runs on its own outside the IDE.

## Evidence to capture

The generated Dockerfile from one two-project app, and the browser network log for a page load in the container showing the static assets returning 200.

## Documentation to use

* [Enable container support in Blazor Web App template, .NET 11 release notes](https://learn.microsoft.com/aspnet/core/release-notes/aspnetcore-11#enable-container-support-in-blazor-web-app-template)
* [Visual Studio container tools](https://learn.microsoft.com/visualstudio/containers/overview)

## What to report

Report results using the format described in the [validation testing manual](https://github.com/dotnet/aspnetcore/issues/68479). Include link to a repository with the test app.

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.