My Experience with .NET MAUI Blazor Hybrid and Creating Installers for Windows

One of the most exciting features of .NET MAUI is Blazor Hybrid, which combines the flexibility of Blazor with the power of native app development.

In my experience with Blazor Hybrid, I found it incredibly useful for leveraging existing Blazor components, eliminating the need for XAML when defining user interfaces. This allowed me to build sophisticated UIs while reusing code, speeding up development. Additionally, pre-built component libraries, like Radzen, seamlessly integrate, making the development process even more efficient.

Why Blazor Hybrid?

Blazor Hybrid offers several advantages that make it an ideal choice for cross-platform development:

1. Component Reusability:

One of the standout benefits of Blazor Hybrid is the ability to reuse Blazor components across different platforms. Whether you’re targeting web, desktop, or mobile, you can write the component once and use it everywhere. This eliminates the need to maintain separate codebases, leading to faster development cycles.

2. No Need for XAML:

Traditional .NET MAUI development relies on XAML for defining user interfaces, which can be a learning curve for many developers. With Blazor Hybrid, there’s no need for XAML — you can build UIs using the familiar Razor syntax, just like in web development. This streamlines the learning process and keeps everything in the realm of HTML and C#.

3. Pre-built Component Libraries:

Blazor Hybrid supports a wide range of existing component libraries, like Radzen, which allows developers to integrate polished, professional UI components without reinventing the wheel. These libraries significantly speed up UI development, providing a robust and ready-to-use solution for common application needs.

Installation Guide for Windows

When working with .NET MAUI and Blazor Hybrid, distributing the application effectively is essential. Instead of using the default MSIX project type, which can generate certificate signing issues — particularly when not distributing through the Microsoft Store — I opted for an alternative approach.

1. Avoiding MSIX and Setting Windows Package Type to None

To bypass MSIX-related issues, I set the Windows Package Type to None, allowing the application to be built without the need for MSIX packaging. This provides more flexibility, especially for scenarios where certificate signing isn't feasible or necessary.

Add this line in your .csproj file.


<WindowsPackageType Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">None</WindowsPackageType>

2. Modifying launchsettings.json

Next, I updated the launchsettings.json file to generate an executable (.exe) file. Below is the modified configuration:

{
  "profiles": {
    "Windows Machine": {
      "commandName": "Project",
      "nativeDebugging": false
    }
  }
}

With this setup, the build process creates a standalone executable that can be run directly without requiring any additional packaging.

3. Creating a Proper Installer

For users who need a proper installer, external tools like Advanced Installer can be used. Advanced Installer offers a streamlined way to create a user-friendly installation package, including setup wizards and shortcut creation, making the deployment process professional and accessible.

By using Advanced Installer, you can easily package the .exe file and its dependencies, allowing users to install your application with just a few clicks.

Conclusion

Working with .NET MAUI and Blazor Hybrid has been an incredibly smooth and efficient experience. The ability to reuse Blazor components across different platforms without the need for XAML has streamlined the development process and saved significant time.

When it comes to distributing the application, avoiding MSIX and generating a standalone executable simplifies the process, especially for environments where certificate signing may be problematic. For those who need a more formal installation experience, using tools like Advanced Installer offers an easy solution to create a professional installer package.

Overall, .NET MAUI Blazor Hybrid has proven to be a powerful tool for cross-platform app development, and the flexibility it provides in both development and deployment makes it a valuable choice for modern developers.

0
An error has occurred. This application may no longer respond until reloaded. Reload x