ElectronNET / Electron.NET

https://github.com/ElectronNET/Electron.NET


Build cross platform desktop apps with .NET Core and ASP.NET NET Core.



Electron.NET Logo

AppVeyor (Win/Linux): Build status

Travis-CI (Win/OSX/Linux): Build Status

Build cross platform desktop apps with .NET Core 2.0 and ASP.NET NET Core.

NuGet:

  • API NuGet
  • CLI NuGet

Usage:

To activate and communicate with the "native" (sort of native...) Electron API include the ElectronNET.API NuGet package in your ASP.NET Core app.

PM> Install-Package ElectronNET.API

Program.cs

You start Electron.NET up with an UseElectron WebHostBuilder-Extension.

public static IWebHost BuildWebHost(string[] args)
{
    return WebHost.CreateDefaultBuilder(args)
        .UseElectron(args)
        .UseStartup<Startup>()
        .Build();
}

Startup.cs

Open the Electron Window in the Startup.cs file:

public async void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    if (env.IsDevelopment())
    {
        app.UseDeveloperExceptionPage();
        app.UseBrowserLink();
    }
    else
    {
        app.UseExceptionHandler("/Home/Error");
    }

    app.UseStaticFiles();

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

    // Open the Electron-Window here
    await Electron.WindowManager.CreateWindowAsync();
}

Start the Application

For the tooling you will need your dotnet-electronize package ElectronNET.CLI NuGet package. This package must be referenced in the .csproj like this:

    <ItemGroup>
       <DotNetCliToolReference Include="ElectronNET.CLI" Version="*" />
    </ItemGroup>

After you edited the .csproj-file, you need to restore your NuGet packages within your Project. Run the follwoing command in your ASP.NET Core folder:

dotnet restore
  • Make sure you have node.js v8.6.0 and on OSX/Ubuntu the electron-packager installed (via "sudo npm install electron-packager --global")

At the first time, you need an Electron.NET Project initialization. Type the following command in your ASP.NET Core folder:

    dotnet electronize init
  • Now a electronnet.manifest.json should appear in your ASP.NET Core project
  • Now run the following:
    dotnet electronize start

Note

Only the first electronize start is slow. The next will go on faster.

Debug

Start your Electron.NET application with the Electron.NET CLI command. In Visual Studio attach to your running application instance. Go in the Debug Menu and click on Attach to Process.... Sort by your projectname on the right and select it on the list.

Usage of the Electron-API

A complete documentation will follow. Until then take a look in the source code of the sample application: ElectronNET.WebApp

Build

Here you need the Electron.NET CLI too. Type following command in your ASP.NET Core folder:

    dotnet electronize build

In your default setting we just build the application for the OS you are running (Windows builds Windows, OSX builds OSX etc.), but this can be changed with:

    dotnet electronize build win
    dotnet electronize build osx
    dotnet electronize build linux

The end result should be an electron app under your /bin/desktop folder.

Note

OSX builds on Windows are currently not supported, because the build just hangs, but I'm not sure why. It works on Linux/OSX however.

Contributing

Feel free to submit a pull request if you find any bugs (to see a list of active issues, visit the Issues section. Please make sure all commits are properly documented.

Authors

  • Gregor Biswanger - (Microsoft MVP, Intel Black Belt and Intel Software Innovator) is a freelance lecturer, consultant, trainer, author and speaker. He is a consultant for large and medium-sized companies, organizations and agencies for software architecture, web- and cross-platform development. You can find Gregor often on the road attending or speaking at international conferences. - Cross-Platform-Blog - Twitter @BFreakout
  • Robert Muehsig - Software Developer - from Dresden, Germany, now living & working in Switzerland. Microsoft MVP & Web Geek. - codeinside Blog - Twitter @robert0muehsig

See also the list of contributors who participated in this project.

License

MIT-licensed

Enjoy!

Ещё не оценен

Последние записи

Архив

2018
2017
2016
2015
2014

Категории

Авторы

Ленты

RSS / Atom