Open isc30 opened 4 years ago
Official bug report: https://github.com/dotnet/aspnetcore/issues/22230
The official answer is that they don't support linking user assemblies so I need to find a way to avoid having module DLLs inside blazor.boot.json
.
I can achieve this in two ways:
Private="false"
so they get excluded from itIn order to get a list of assemblies that shouldn't be included as part of the boot, I will need to create an MSBuild Task that does:
Private="false"
Detecting the references that only affect Modules project is not trivial, I will just wait for the "linking user assemblies" feature to be available.
Very similar to my issue https://github.com/dotnet/aspnetcore/issues/25949
The linker in Blazor WASM is including dependencies that aren't in use (in normal scenarios these would be stripped out by the compiler, which is what happens with the linker disabled (ok)).
When adding a reference (RCL project/nuget) to a project with
Microsoft.AspNetCore.Components.WebAssembly.Build
andBlazorWebAssemblyEnableLinking
set totrue
, the linker will add the dependency project as a boot dependency insideblazor.boot.json
even if it's not used at all.If this reference is not used, the linker should detect it and not add it as a boot project. I suspect the problem is somewhere where we take the linker output and enumerate the blazor binaries based on it.
This issue doesn't happen with
BlazorWebAssemblyEnableLinking
disabled (the unused project is not even inside_framework/_bin
).To Reproduce
Please follow the steps to get this reproduced on your own repository. In order to check the bug, this minimal example repository with the bug can be used.
Properly Working Example: With no Linker
<BlazorWebAssemblyEnableLinking>false</BlazorWebAssemblyEnableLinking>
wwwroot/test.css
as StaticWebAssetlib
fromhost
and use the Component from itlib
appears insideblazor.boot.json
and gets downloaded during startup (ok)_content/lib/test.css
and see that the StaticWebAsset is available (ok)lib
by not using the Component anymore so the compiler strips it outblazor.boot.json
and doesn't get downloaded during startup (ok)_content/lib/test.css
is still available (ok)Buggy Example: With Linker enabled
<BlazorWebAssemblyEnableLinking>true</BlazorWebAssemblyEnableLinking>
lib
fromhost
and use the Component from itlib
appears insideblazor.boot.json
and gets downloaded during startup (ok)_content/lib/test.css
and see that the StaticWebAsset is available (ok)lib
by not using the Component anymore so the compiler strips it outblazor.boot.json
and still gets downloaded during startup (fail)_content/lib/test.css
is still available (ok)Further technical details
Comments
This is a rather big bug. When including a NuGet package and using a small portion of it, the linker will still add every sub-reference, even if not used and the DLL could be skipped.
This should still preserve StaticWebAssets from the projects that don't need a runtime.