Deployment in Blazor
9 Dec 20222 minutes to read
This section provides information about deploying Blazor applications with the Syncfusion Blazor components.
Refer to Host and deploy ASP.NET Core Blazor topic for more information.
Publish Blazor Application with Visual Studio
- Right-click on the project in the
Solution Explorerand select
- Then, select the
Folderoption and select the publishing target location.
- Check the configuration as Release by clicking the
Advanced...option below the target location.
Blazor Server side application, set Deployment Mode as
Self-Contained. Because some dependencies are not loaded properly when the published folder is hosted.
Refer here for publishing the application to Azure App Service using Visual Studio.
Publish Blazor Application with CLI
Packing the application and its dependencies into a folder for deployment to a hosting system by using the
dotnet publish command.
For CLI deployment, run the following command from your root directory.
dotnet publish -c Release
For Blazor Server CLI deployment.
dotnet publish -c Release --self-contained true -r win-x86
Refer to the dotnet publish - arguments to learn about various optional arguments. Use the following command to specify the path for the output directory.
dotnet publish -c Release -o <output directory>
If the output directory is not specified, it defaults to
./bin/[configuration]/[framework]/publish/for a framework-dependent deployment and
./bin/[configuration]/[framework]/[runtime]/publish/for a self-contained deployment.
If the path is relative, the output directory generated is relative to the project file location, not to the current working directory. Now, the published folder can be hosted in IIS or Azure app service.
Ahead-of-time (AOT) compilation in Blazor WebAssembly
Blazor WebAssembly supports ahead-of-time (AOT) compilation which provides improved runtime performance at the expense of a larger app size. Refer to Ahead-of-time (AOT) compilation topic to learn more about how it works and how to enable.
Enable AOT in the application
To enable AOT compilation in the application, add
RunAOTCompilation options with value to
true in the Blazor WebAssembly app’s project file.
<PropertyGroup> <RunAOTCompilation>true</RunAOTCompilation> </PropertyGroup>
- Host and Deploy Blazor
- Host and deploy Blazor Server
- Host and deploy ASP.NET Core Blazor WebAssembly
- Publish a Web app to Azure App Service using Visual Studio
- Deploy ASP.NET Core apps to Azure App Service
- Deploy Blazor WASM App to Cloudflare
- Publish a Blazor WebAssembly app and .NET API with Azure Static Web Apps