Skip to content

Instantly share code, notes, and snippets.

@pranavkm
Last active April 22, 2021 18:45
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pranavkm/1ca9eca9605ebc89161cb33e02e74e85 to your computer and use it in GitHub Desktop.
Save pranavkm/1ca9eca9605ebc89161cb33e02e74e85 to your computer and use it in GitHub Desktop.
AOT for Blazor
  • Install the latest preview SDK:

  • Install the blazor-aot tool and acquire the SDK

    • dotnet new nugetconfig
    • edit the nuget.config file to include nightly feed:
      + <add key="aspnetcore" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json" />
    • Install the tool
      dotnet new tool-manifest
      dotnet tool install dotnet-install-blazoraot --version 6.0.0-*
      
    • Run the tool to install workload + packs
      dotnet install-blazoraot
      
    • Due to a bug in the workload authoring, python needs to be manually installed on Windows and MacOS. Follow the instructions here https://emscripten.org/docs/getting_started/downloads.html#platform-specific-notes to acquire it.
  • Create a new Blazor WebAssembly app and enable AOT

    • dotnet new blazorwasm
    • Open up the project file and configure it to use AOT
      <PropertyGroup>
         <RunAOTCompilation>true</RunAOTCompilation>
      </PropertyGroup>
  • dotnet publish

@lewing
Copy link

lewing commented Mar 19, 2021

should be fine without invariant mode these days

@captainsafia
Copy link

dotnet install-blazoraot

I think this should be dotnet dotnet-install-blazoraot?

@radekdoulik
Copy link

radekdoulik commented Mar 25, 2021

I tried it today and had trouble with the latest version of the dotnet-install-blazoraot tool.

I was able to overcome it by installing the preview.3 version, like this: dotnet tool install dotnet-install-blazoraot --version 6.0.0-preview.3.

Update: recently I used preview.4 instead

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