How to server blazor.web.js when the build version and runtime version don't match
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
Aspire dashboard is built for .NET 8. However, it can run on newer versions of .NET if that is only what is installed on a machine.
For example, user's machine only has .NET 10 installed, so the dashboard will run on .NET 10.
That causes problems with the blazor.web.js file. It used to be an embedded resource. It moved to being a static asset in .NET 10 I believe.
To support .NET 10 Aspire took a copy of the blazor.web.js file and referenced it directly. See https://github.com/microsoft/aspire/pull/9733. This fix has now broken because new methods have been added in .NET 11, e.g. `refreshObservables`. We now need to have .NET 10 and .NET 11 copies of blazor.web.js file.
I tried conditionally calling `MapStaticAssets` using reflection when the runtime is .NET 11, but blazor.web.js still wasn't available because the dashboard targets net8.0 and it seems like it is a build action to include blazor.web.js which doesn't happen in .NET 8.
It's unfortunate that blazor.web.js file is no longer embedded in Blazor because using the correct runtime version just automatically worked.
Two questions:
1. What can be done to improve this situation right now?
2. Will moving to .NET 10 in the future solve this issue? blazor.web.js file will now be available, but will it be the correct version depending on the runtime? i.e. will Blazor app that is built for .NET 10 work when running in .NET 11?
Contributor guide
Assessment
This issue has not been assessed yet.