Skip to content

A WebKitGtk WebView for running Blazor Hybrid applications.

License

Notifications You must be signed in to change notification settings

JinShil/BlazorWebView

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BlazorWebView

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.

Why?

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#.

How?

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.

Screenshot

Demonstration

Using a Linux terminal

git clone https://github.com/JinShil/BlazorWebView.git
cd BlazorWebView/WebKitGtk.Test
dotnet run

Using Visual Studio Code

On a Linux computer, simply open this repository in Visual Studio Code and press F5 to start a debug session.

Ubuntu 24.04 bwrap error fix

Running the demo project may fail with the following error on ubuntu 24.04:

bwrap: setting up uid map: Permission denied

This is due to Ubuntu developers deciding to use Apparmor to restrict the creation of user namespaces. To resolve this create a file named /etc/apparmor.d/bwrap with the following contents:

abi <abi/4.0>,
include <tunables/global>

profile bwrap /usr/bin/bwrap flags=(unconfined) {
  userns,

  # Site-specific additions and overrides. See local/README for details.
  include if exists <local/bwrap>
}

Followed by a reboot. (Note: this fix was found here)

Usage

See the project in WebKitGtk.Test for an example illustrating how to create a Blazor Hybrid application using the BlazorWebView.

You may need to install the following packages:

  • libadwaita-1-0
  • libwebkitgtk-6.0-4

Status

This project was tested on:

  • Windows Subsystem for Linux
  • Raspberry Pi Bullseye 64-bit
  • Debian Bullseye 64-bit.
  • Ubuntu 24.04 LTS desktop amd64

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.

About

A WebKitGtk WebView for running Blazor Hybrid applications.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published