Creating A Blazor Hybrid Application In macOS

Blazor Hybrid is an amazing technology that works in conjunction with .NET MAUI to allow developers to work with Blazor (using C#, HTML, and CSS) to create multiplatform applications.

In the official documentation, you can find more information about the features that you can use: ASP.NET Core Blazor Hybrid | Microsoft Learn

Also, there is a great article about Blazor Hybrid and how to start with this technology here in C# corner: Build A Blazor Hybrid App with .NET MAUI for Cross-Platform Application (c-sharpcorner.com)

To work with Blazor Hybrid on macOS we need the following requirements,

  • .NET 7 or higher
  • MAUI Workloads for dotnet CLI
  • Visual Studio for Mac 17.x (Optional to work with this IDE)
  • macOS 10.15 or later, with Mac Catalyst
  • Xcode 14.1 or later

After installing all these requirements, you can install .NET MAUI and create a demo for Blazor Hybrid.

First, let's install the workload using the following command,

sudo dotnet workload install maui

After that, you can use the command dotnet new maui-blazor to create a new Blazor Hybrid App.

dotnet new maui-blazor

You can open this project using your favorite IDE for example Visual Studio Code

Creating a Blazor Hybrid Application in macOS

You can execute the project using the CLI with the following command,

dotnet build -t:Run -f net7.0-maccatalyst

You will get the base application running as a desktop app in macOS,

Creating a Blazor Hybrid Application in macOS

You can also use Visual Studio for Mac to create your project. Let's open Visual Studio for Mac and create a new project. We can find the Blazor Hybrid template as .NET MAUI Blazor App

Creating a Blazor Hybrid Application in macOS

Then we need to select the target framework, then set a name, and create the project. After creating the project we can use the run option to execute the project.

You can also create the App file in order to share your app using the following command,

dotnet build -f:net6.0-maccatalyst -c:Release

NOTES

If you have problems with xCode remember to accept the agreement and install the last version of the tool in order to have all that you need to execute the Blazor Hybrid project

Creating a Blazor Hybrid Application in macOS

Open Xcode and follow the instructions,

Creating a Blazor Hybrid Application in macOS

Install the target platforms,

Creating a Blazor Hybrid Application in macOS


Similar Articles