please check out the orginal post on Cooldown.io
Getting started with Blazor and Electron.NET
- What is Blazor?
- From the Blazor Github, Blazor is a .NET web framework using C#/Razor and HTML that runs in the browser with WebAssembly."
- What is Electron.NET?
- From the Electron.NET Github, "Electron.NET is a wrapper around a "normal" Electron application with an embedded ASP.NET Core application".
- So that this article does not get dated with irreverent information quickly I will be using information from other resources.
- getting started for blazor
- node.js v8.6.0+
- electron-packager --global
- If you do not want to follow the steps below, or just want to check out the code I reproduced the following steps in a repo. Besure you all the required perquisites
- If you have not done so, check out the getting started for blazor to install perquisites for this tutorial
- Create a new Blazor (ASP.NET Core hosted) project
- Install ElectronNET.API
PM> Install-Package ElectronNET.API
- In %projectname%.Server/Program.cs change BuildWebHost to use Electron
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseElectron(args)
.UseStartup<Startup>()
.Build();
- In %projectname%.Server/Startup.cs change Configure to open Electron
app.UseBlazor<Client.Program>();
Task.Run(async () => await Electron.WindowManager.CreateWindowAsync());
- Add cli tooling to %projectname%.Server
<ItemGroup>
<DotNetCliToolReference Include="ElectronNET.CLI" Version="0.0.9" />
</ItemGroup>
**Note at the time the current version is 0.0.9**
dotnet restore
- Install electron packager
sudo npm install electron-packager --global
- Init and Run
dotnet electronize init
dotnet electronize start
I claim none of this work as my own and proudly support the work of both the aspnet team on Blazor and the team developing Electron.NET, this post is intended to raise awareness of some of the possibilities for a prototype. Most of the "Setting up a simple project" is directly from both Electron.NET's and Blazor's githubs.