In your csproj file, add the following:
<Target Name="AddCustomLinkerDescriptor" AfterTargets="_CollectBlazorLinkerDescriptors">
<ItemGroup>
<BlazorLinkerDescriptor Include="CustomLinkerConfig.xml" />
</ItemGroup>
</Target>
Then create a file called CustomLinkerConfig.xml
in the same directory as that csproj file, containing the following:
<linker>
<!-- TODO: Change this to the name of the assembly you want the linker to preserve -->
<assembly fullname="System.Linq" />
</linker>
Edit this config file to specify which assembly you want the linker to skip (i.e., replace System.Linq
with something else). For more info about the allowed config settings, see https://github.com/mono/linker/blob/master/linker/README.md#syntax-of-xml-descriptor