Thanks to visit codestin.com
Credit goes to github.com

Skip to content

araneta/BlazorWebView

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

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

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.

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 poject was tested on Windows Subsystem for Linux, Raspberry Pi Bullseye 64-bit, and Debian Bullseye 64-bit.

Note that on the latest Raspberry Pi Bookworm OS, you will likely encounter raspberrypi/linux#5750. You can work around the issue by adding webView.GetSettings().SetHardwareAccelerationPolicy(WebKit.HardwareAccelerationPolicy.Never);.

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

Languages

  • C# 85.9%
  • HTML 14.1%