This is a small desktop app in Avalonia that hosts a WebView window - an Angular application consuming a .NET backend in desktop form.
I was looking for a Tauri.js alternative where I could keep the backend in .NET instead of Rust. After finding nothing, I went on a journey to build a small project like that myself. The goals were to create a desktop app whose backend will be written in .NET and the frontend in one of the popular JS frameworks (in this case, Angular).
- Avalonia UI
- ASP.NET Core
- Angular 20
- Avalonia boots up a desktop window that hosts a WebView (
WebView.Avalonia
). - It runs an ASP.NET Core API with a simple
/api/metadata
REST endpoint. - In Debug mode, the WebView points to the Angular dev server at
http://localhost:4200
. - In Release mode, the WebView points to the embedded ASP.NET Core API, which serves the endpoints and the Angular bundle previously built via
npm run build
.
- Node.js
- .NET SDK 9.0
- Visual Studio 2022, VS Code or JetBrains Rider
- Install dependencies
npm install
- Start the Angular dev server
ng serve
- Run the desktop app
Open the solution in Visual Studio or Rider and run the
DesktopApp
project in Debug mode. It will open the Avalonia window and loadhttp://localhost:4200
inside the WebView.
- Build the frontend
npm run build
- Run the desktop app
Open the solution in Visual Studio or Rider and run the
DesktopApp
project in Release mode. Alternatively, publish the desktop app in Release mode and then open it. It will open the Avalonia window and load the frontend served from the embedded ASP.NET Core server (defaults tohttp://localhost:54321
, or another free port) from thewwwroot/
directory inside the WebView.
It's very unfortunate that .NET doesn't have something like Tauri. The closest thing I found was ElectronJS in .NET but it hasn't been updated in a while and it wouldn't work the way I expected it to. This was a fun project to spend a few days on and I am surprised it worked out the way it did.
Issues and PRs are welcome as well as ideas to improve the "template" or make it work for other JS frameworks. In case anyone actually creates a proper framework like Tauri, I would love to know about it.
This project is licensed under the MIT License. See the LICENSE file for details.