Electron.net: The Stack overflow wienies won't allow a question to be posted - so I'm asking here.

Created on 26 Sep 2019  路  24Comments  路  Source: ElectronNET/Electron.NET

Here is the question: https://stackoverflow.com/questions/58103860/when-will-electron-net-support-net-core-3

When will Electron.NET support .NET Core 3?

Thank you for the information,

Karl

question

Most helpful comment

@kdawg1406 Sorry to answer, but as i have tested extensively different scenario types about Blazor.

  1. Yes
  2. Yes

The first scenario is the more extensive one if you need to debug and test. As Blazor server-side client behavior is executed on a regular ASP.NET Core server, the one served with your ElectronNET app embedding it, in this context you have access to all the C# context, client C# one and the server one (in reality they are all the same in the same memory context).

Except if you need to debug Javascript, of course you will have to open the developer toolbox in your Electron app like any Electron app.

The second scenario is also possible if you switch to the Blazor client side rendering, nothing prevent you to do it. Actually, if you don't have a complex Blazor setup, you only need to replace blazor.server.js reference in your _Host.cshtml to blazor.webassembly.js , that's all! In this scenario C# code will be executed in the browser and not remotly in ASP.NET Core server.

It can be less convenient to debug your C# code as there is only experimental debug tooling at the moment for the Blazor client-side model. The limitation is not related to Electron.

My additional though, you may have little different behaviors between .NET Core and WASM Blazor version, because the core of your app tend to be multi-tenant with the server-side version, and not in client version (except any remote WebAPI services of course !).

All 24 comments

Disclaimer: I'm not working for ElectronNET.

If you want to test with .NET Core 3.0 before it is officially migrated from ElectronNET team:

  • Fork ElectronNET project
  • On your forked repo folder, execute the following git command:
git pull https://github.com/raz-canva/Electron.NET raz/dotnet-core-preview-7-with-packages

It's actually a PR not yet merged of @raz-canva for .NET Core 3.0 . Even if it is mentionning preview7 in the branch name, there is no reference in csproj so it's good.

  • Install .NET Core 3.0 of course
  • In your ElectronNET web app csproj, add the following lines under TargetFramework:
<TargetFramework>netcoreapp3.0</TargetFramework>
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
<AspNetCoreModuleName>AspNetCoreModule</AspNetCoreModuleName>
  • In Startup.cs add app.UseRouting(); before app.UseEndpoints call.

Then start your app, it should publish and launch correctly, all with .NET Core 3.0

@Daddoon thank you very much, best to you, Karl

You are welcome ! As i have seen on you profile is it for testing your Moo2App on ElectronNET with Blazor ?

If yes, at some point you may enjoy to use my plugin BlazorMobile to also test with your upcoming Blazor app on Mobile devices as standalone app.

@Daddoon The app I'm building this weekend is Blazor Power Toys. A cross-platform app that allows a developer to select a dll from a Blazor project, I'll reflect the assembly, allow the developer to select a type and then use that type to drive drag and drop experience for creating an Edit Form.

When done, the tool will create the HMTL / C# markup and put into the clipboard that can be pasted into the app. I have the same type of tool for all XAML platforms, XAML Power Toys.

I'm using Electron so that developers on Windows, Mac, Visual Studio or Visual Studio Code and use the tool without me having to write many versions.

I have other apps that I'll be writing soon after this using Blazor & Electron.NET.

I'll look at BlazorMobile, thank you. When I get Blazor Power Toys done, I'll be writing Blazor Moo2U.

Thank you again for the assistance, greatly appreciated.

Look like a pretty interesting tool !
Do you have any official repo page on github to star that ?

Thanks for your feedback!

@Daddoon I followed the directions but am getting the below errors.

I assume I use the start.cmd in the root of the app to start it, correct?

Thank you!

Any suggestions, I have .NET Core 3 RTM installed. Do I need any other things installed? Not sure how to correct the ILoggerFactory errors.

My Startup file:

public class Startup
    {
        public IConfiguration Configuration { get; }

        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            app.UseRouting();
            app.UseEndpoints();
            app.UseStaticFiles();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });



            if(HybridSupport.IsElectronActive)
            {
                ElectronBootstrap();
            }
        }

        public async void ElectronBootstrap()
        {
            var browserWindow = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions
            {
                Width = 1152,
                Height = 940,
                Show = false
            });

            await browserWindow.WebContents.Session.ClearCacheAsync();

            browserWindow.OnReadyToShow += () => browserWindow.Show();
            browserWindow.SetTitle(Configuration["DemoTitleInSettings"]);
        }
    }

Errors

C:\Users\saved\.nuget\packages\microsoft.build.tasks.git\1.0.0-beta2-18618-05\build\Microsoft.Build.Tasks.Git.targets(28,5): warning : Repository has no remote. [C:\Code\BlazorPowerToys\Electron.NET\ElectronNET.API\ElectronNET.API.csproj]
C:\Users\saved\.nuget\packages\microsoft.build.tasks.git\1.0.0-beta2-18618-05\build\Microsoft.Build.Tasks.Git.targets(36,5): warning : Repository has no commit. [C:\Code\BlazorPowerToys\Electron.NET\ElectronNET.API\ElectronNET.API.csproj]
C:\Users\saved\.nuget\packages\microsoft.sourcelink.common\1.0.0-beta2-18618-05\build\Microsoft.SourceLink.Common.targets(53,5): warning : Source control information is not available - the generated source link is empty. [C:\Code\BlazorPowerToys\Electron.NET\ElectronNET.API\ElectronNET.API.csproj]
  ElectronNET.API -> C:\Code\BlazorPowerToys\Electron.NET\ElectronNET.API\bin\Debug\netcoreapp2.2\ElectronNET.API.dll
Startup.cs(28,56): warning CS0618: 'IHostingEnvironment' is obsolete: 'This type is obsolete and will be removed in a future version. The recommended alternative is Microsoft.AspNetCore.Hosting.IWebHostEnvironment.' [C:\Code\BlazorPowerToys\Electron.NET\ElectronNET.WebApp\ElectronNET.WebApp.csproj]
Controllers\TrayController.cs(11,26): warning CS0618: 'IHostingEnvironment' is obsolete: 'This type is obsolete and will be removed in a future version. The recommended alternative is Microsoft.AspNetCore.Hosting.IWebHostEnvironment.' [C:\Code\BlazorPowerToys\Electron.NET\ElectronNET.WebApp\ElectronNET.WebApp.csproj]
Controllers\TrayController.cs(13,31): warning CS0618: 'IHostingEnvironment' is obsolete: 'This type is obsolete and will be removed in a future version. The recommended alternative is Microsoft.AspNetCore.Hosting.IWebHostEnvironment.' [C:\Code\BlazorPowerToys\Electron.NET\ElectronNET.WebApp\ElectronNET.WebApp.csproj]
Startup.cs(30,13): error CS1929: 'ILoggerFactory' does not contain a definition for 'AddConsole' and the best extension method overload 'ConsoleLoggerExtensions.AddConsole(ILoggingBuilder)' requires a receiver of type 'ILoggingBuilder' [C:\Code\BlazorPowerToys\Electron.NET\ElectronNET.WebApp\ElectronNET.WebApp.csproj]
Startup.cs(37,8): error CS7036: There is no argument given that corresponds to the required formal parameter 'configure' of 'EndpointRoutingApplicationBuilderExtensions.UseEndpoints(IApplicationBuilder, Action<IEndpointRouteBuilder>)' [C:\Code\BlazorPowerToys\Electron.NET\ElectronNET.WebApp\ElectronNET.WebApp.csproj]
Startup.cs(40,13): warning MVC1005: Using 'UseMvc' to configure MVC is not supported while using Endpoint Routing. To continue using 'UseMvc', please set 'MvcOptions.EnableEndpointRouting = false' inside 'ConfigureServices'. [C:\Code\BlazorPowerToys\Electron.NET\ElectronNET.WebApp\ElectronNET.WebApp.csproj]

The sample project you created is maybe a little outdated compared to the one shipped in the .sln in thr PR.

Also with the code you copied here, i don't see the change i mentionned to you.

In your project modify your Program.cs (adapt with your namespace):

using ElectronNET.API;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Logging;

namespace ElectronNET.WebApp
{
    public class Program
    {
        public static void Main(string[] args)
        {
            BuildWebHost(args).Run();
        }

        public static IWebHost BuildWebHost(string[] args)
        {
            return WebHost.CreateDefaultBuilder(args)
                .ConfigureLogging((hostingContext, logging) => { logging.AddConsole(); })
                .UseElectron(args)
                .UseStartup<Startup>()
                .Build();
        }
    }
}

Your Startup.cs should look close to something like this (except of the ElectronBootStrap part where you do it as you like with Electron):

using ElectronNET.API;
using ElectronNET.API.Entities;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace ElectronNET.WebApp
{
    public class Startup
    {
        public IConfiguration Configuration { get; }

        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            services.AddRazorPages();
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseStaticFiles();

            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}");
            });



            if(HybridSupport.IsElectronActive)
            {
                ElectronBootstrap();
            }
        }

        public async void ElectronBootstrap()
        {
            var browserWindow = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions
            {
                Width = 1152,
                Height = 940,
                Show = false
            });

            await browserWindow.WebContents.Session.ClearCacheAsync();

            browserWindow.OnReadyToShow += () => browserWindow.Show();
            browserWindow.SetTitle(Configuration["DemoTitleInSettings"]);
        }
    }
}

@Daddoon thank you, making adjustments now. This is such a great project.

Hey Community,
I'm currently working on the next release with Electron 6 and .NET Core 3 support (Electron.NET 6.30.15). I麓m working on this project in my free time and currently I麓m heavily booked out by the end of the year as freelancer. But if all goes well, the next release should be released over this weekend. Otherwise a week later (sorry).

@Daddoon Thank you for your masterpiece with Electron.NET! <3

@kdawg1406 Also for testing, you just have to launch the Debug from your Web app, that will internally call electronize start from your working folder.

Also, if you still have issue with current CLI and API being in .Net Core 2.2 you may call:

buildReleaseNuGetPackages.cmd

Then from your root ElectronNET project folder call:

dotnet tool install --global --add-source="./artifacts" ElectronNET.CLI
dotnet tool install --global --add-source="./artifacts" ElectronNET.API

In order to install the local tool packages you just generated

If already installed you may have to uninstall them with dotnet tool uninstall.

@GregorBiswanger Very good news ! Wishing that the Chrome Extensions PR will be included with your release also, so i will be able to update my plugin very soon!

I can wait don't worry haha. I have many task to do in my task list for my next milestone, but a lot are about upgrading Electron behaviors to the one already coded for Xamarin.

Thank you for your masterpiece too! ElectronNET is a dream tool for any .NET Developer !
Thanks for porting this!

Yes, your PR will be there :) Although I will still run a few tests and check your code again, not that there should be problems somewhere. But in principle, your PR is scheduled for the next version.

@GregorBiswanger thank you very much, outstanding work sir!

@GregorBiswanger Cool ! Yes of course about PR testing. Thanks for your feedback !

@Daddoon I have many errors in the code that I don't understand. I'm going to wait until the RTM of Electron.NET. Thank you very much for your response. My inexperience is probably the issue. I can wait a few weeks, no problem!

Haha okay no problems ! This come very soon.

@GregorBiswanger question: When Electron.NET RTM's can I create one or both of these types of projects?

  1. Electron.NET and Server-Side Blazor?
  2. Electron.NET, ASP.NET Core 3 WebAPI, and Client-Size Blazor?

I just don't have enough context yet to fully understand how Electron.NET fits in with all this.

After you RTM, I'll blog and make a YouTube video for using Electron.NET and Blazor.

Thank you!

Karl

@kdawg1406 Sorry to answer, but as i have tested extensively different scenario types about Blazor.

  1. Yes
  2. Yes

The first scenario is the more extensive one if you need to debug and test. As Blazor server-side client behavior is executed on a regular ASP.NET Core server, the one served with your ElectronNET app embedding it, in this context you have access to all the C# context, client C# one and the server one (in reality they are all the same in the same memory context).

Except if you need to debug Javascript, of course you will have to open the developer toolbox in your Electron app like any Electron app.

The second scenario is also possible if you switch to the Blazor client side rendering, nothing prevent you to do it. Actually, if you don't have a complex Blazor setup, you only need to replace blazor.server.js reference in your _Host.cshtml to blazor.webassembly.js , that's all! In this scenario C# code will be executed in the browser and not remotly in ASP.NET Core server.

It can be less convenient to debug your C# code as there is only experimental debug tooling at the moment for the Blazor client-side model. The limitation is not related to Electron.

My additional though, you may have little different behaviors between .NET Core and WASM Blazor version, because the core of your app tend to be multi-tenant with the server-side version, and not in client version (except any remote WebAPI services of course !).

@Daddoon @GregorBiswanger thank you both. After watching the getting started YouTube video I understand a lot more now.

For now, I can develop my server-side Blazor app and when Electron.NET support .NET Core 3, I can easily convert the app.

Best to both of you!!

@Daddoon @GregorBiswanger Question: Will I be able to open a dialog and get back a path from the dialog? I've used Electron before and created some high octane applications using Angular.

Can I still access the Electron Main Process and create a dialog from the Electron.NET Blazor app as shown in these Electron docs? https://electronjs.org/docs/api/dialog

Basically, I'm trying to wrap my head around how Angular and Blazor apps differ or are similar in the way the work with Electron. Thank you!

Maybe Electron.NET has a built-in dialog?

Actually ElectronNET cover nearly all the essential API you need.

Have you looked over the Electron.NET API Demos ? This demo app is self explanatory as the demo itself explain how it works, with code and test buttons. Just launch it.

Nearly all Electron API should be covered with a .NET API.
For your question, if my memory is good, take a look at Electron.Dialog namespace. You should have a ShowOpenDialogAsync method or something like that available.

@Daddoon thank you very much for your patience and assistance. I'll read the docs and research the demos before posting more questions. This product is much more mature than I thought and I need to learn the happy path to productivity that produces awesome applications.

I have three apps queued up when Electron.NET supports .NET Core 3 out of the box.

I'll be donating to @GregorBiswanger when .NET Core 3 support ships. Such a great product.

Hey Community,
I'm currently working on the next release with Electron 6 and .NET Core 3 support (Electron.NET 6.30.15). I麓m working on this project in my free time and currently I麓m heavily booked out by the end of the year as freelancer. But if all goes well, the next release should be released over this weekend. Otherwise a week later (sorry).

@GregorBiswanger how is your update to support .NET Core 3 going? Thank you for your time and hard work.

Actually, even if the ElectronNET.API and ElectronNET.CLI are in .NET Core 2.2, you can create an .NET Core 3.0 project, and it should work.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

seanmars picture seanmars  路  5Comments

ernestotw85 picture ernestotw85  路  3Comments

ThuCommix picture ThuCommix  路  3Comments

yoDon picture yoDon  路  4Comments

iqmeta picture iqmeta  路  3Comments