Skip to content

Instantly share code, notes, and snippets.

@SteveSandersonMS
Last active August 29, 2018 09:33
Show Gist options
  • Save SteveSandersonMS/48eff1f6a868037365db8a33c1b1cea3 to your computer and use it in GitHub Desktop.
Save SteveSandersonMS/48eff1f6a868037365db8a33c1b1cea3 to your computer and use it in GitHub Desktop.

Blazor: Adding a custom linker config

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment