A WebKitGTK WebView, utilizing Gir.Core, for running Blazor Hybrid applications on Linux without the need to compile a native library. It is analagous to the Winforms BlazorWebView or the WPF BlazorWebView, but for Linux instead of Windows.
Blazor Hybrid apps allow one to create Blazor desktop applications that uses the local machine's .NET runtime (not Blazor WASM), has full access to local resources (not sandboxed), and does not require hosting through a web server (e.g. Blazor server). It is just like any other desktop application written in C#, but uses Blazor and web technologies to implement the user interface.
Microsoft has decided to not support Maui on Linux, so there is currently no way to create Blazor Hybrid apps on Linux using only C#.
BlazorWebView uses some of the same code as Steve Sanderson's WebWindow and leverages Microsoft's WebView infrastructure to get Blazor Hybrid working. However, it differs from WebWindow in that it doesn't require one to compile a native shared library in C++, instead utilizing Gir.Core to call into the native libraries. This has the benefit that, as long as the native libraries are installed on the Linux system, one only needs to use the dotnet
CLI to build and run BlazorWebView.
git clone https://github.com/renick/BlazorWebView.git
cd WebKitGtk/WebKitGtk.Test
dotnet run
On a Linux computer, simply open this repository in Visual Studio Code and press F5 to start a debug session.
See the project in WebKitGtk.Test for an example illustrating how to create a Blazor Hybrid application using the BlazorWebView.
This poject was tested on Windows Subsystem for Linux, Raspberry Pi Bullseye 64-bit, and Debian Bullseye 64-bit.
The root .vscode directory has the necessary configuration files to build, deploy, and debug a Raspberry Pi from a Debian Bullseyse 64-bit workstation PC.