Blazor WebAssembly fails to hydrate when "build --no-restore"
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
[MauiApp6.zip](https://github.com/user-attachments/files/23828691/MauiApp6.zip)
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Describe the bug
The symptoms are: blazor.web.js request always gives 404, no hydration happening
This is apparently caused by wasm-tools workload. When "dotnet built" executed with "--no-restore", it silently ignores problems, and ends up with broken deployment after publish.
### Expected Behavior
--no-restore should work properly (assuming RuntimeIdentifiers specified either in proj or in cli) and hydration should work after this.
Or restore should at least fail and describe how to pre-load workloads on restore stage.
It is not expected the app to be built and published successfully and then fail hydration and everything in runtime after deployment (both docker and prod).
### Steps To Reproduce
Create a Maui Blazor Hybrid Temaplate. Choose InteractiveRenderMode: WebAssemlby.
Create a default docker support. Build and Run docker - everything works, it hydrates (note: not VS F5 with docker, but from CLI docker build, docker run).
Now in Dockerfile, for "build" and "publish" add "--no-restore" to make sure it does not waste time on nugets after restore layer.
Run it - now it silently fails to hydrate, Network Requests shows blazor.web.js 404
### Exceptions (if any)
_No response_
### .NET Version
10.0.0
### Anything else?
It took a day to narrow it down to this. The issue is silent and was discovered during upgrade Net9 -> Net10 following new template.
In net9 project I use linux-musl-x64 for host and browser-wasm for client. After this I used to disable nuget source and do --no-restore everywhere after restore layer is done.
Now it no longer works and silently fails. We need a reliably way keep nuget restore on a separate docker layer
Contributor guide
Assessment
This issue has not been assessed yet.