DEV Community

Chris Richmond
Chris Richmond

Posted on

Blazor WASM Linking

Problem:
Your WASM application works fine in debug, but when you deploy you start seeing issues where methods and other such things are missing.

Possible Solution: Blazor WASM is similar to Xamarin development in that you want to ensure your app is as small as possible. To that goal, by default the build will strip out any perceived unneeded code from your project. This can have some unforeseen consequences unfortunately. To avoid this consider adding the following properties to your project file:

Disable ALL linking

<PropertyGroup> 
<BlazorWebAssemblyEnableLinking>false</BlazorWebAssemblyEnableLinking>
</PropertyGroup>
Enter fullscreen mode Exit fullscreen mode

Disable linking in a more nuanced fasion

<ItemGroup>
  <BlazorLinkerDescriptor Include="LinkerConfig.xml" />
</ItemGroup>
Enter fullscreen mode Exit fullscreen mode

If you go with the LinkerConfig.xml please review the reference for guides on how to populate the LinkerConfig.xml

Reference: https://learn.microsoft.com/en-us/aspnet/core/blazor/host-and-deploy/configure-linker?view=aspnetcore-3.1

Top comments (0)