Files
Electron.NET/README.md

138 lines
4.9 KiB
Markdown
Raw Normal View History

2017-10-28 23:11:41 +02:00
[![Electron.NET Logo](https://github.com/ElectronNET/Electron.NET/blob/master/assets/images/electron.net-logo.png)](https://github.com/ElectronNET/Electron.NET)
2017-10-17 15:32:09 +02:00
2017-10-24 22:29:28 +02:00
2017-10-24 22:29:13 +02:00
AppVeyor (Win/Linux): [![Build status](https://ci.appveyor.com/api/projects/status/q95h4xt14papwi05/branch/master?svg=true)](https://ci.appveyor.com/project/robertmuehsig/electron-net/branch/master)
2017-10-24 22:29:28 +02:00
2017-10-24 22:29:13 +02:00
Travis-CI (Win/OSX/Linux): [![Build Status](https://travis-ci.org/ElectronNET/Electron.NET.svg?branch=master)](https://travis-ci.org/ElectronNET/Electron.NET)
2017-10-16 23:16:50 +02:00
Build cross platform desktop apps with .NET Core 2.0 and ASP.NET NET Core.
2017-10-03 23:37:46 +02:00
2017-10-17 23:48:02 +02:00
# Usage:
2017-10-18 22:58:01 +02:00
To activate and communicate with the "native" (sort of native...) Electron API include the [ElectronNET.API NuGet package](https://www.nuget.org/packages/ElectronNET.API/) in your ASP.NET Core app.
2017-10-17 23:48:02 +02:00
2017-10-18 22:58:01 +02:00
````
PM> Install-Package ElectronNET.API
````
## Program.cs
You start Electron.NET up with an `UseElectron` WebHostBuilder-Extension.
```csharp
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:
```csharp
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](https://www.nuget.org/packages/ElectronNET.CLI/). This package __must__ be referenced in the .csproj like this:
2017-10-17 23:48:02 +02:00
2017-10-17 23:49:24 +02:00
```
2017-10-17 23:48:02 +02:00
<ItemGroup>
<DotNetCliToolReference Include="ElectronNET.CLI" Version="*" />
</ItemGroup>
2017-10-17 23:49:24 +02:00
```
2017-10-18 22:58:01 +02:00
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
```
2017-10-17 23:49:24 +02:00
2017-10-18 22:58:01 +02:00
* 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:
2017-10-17 23:48:02 +02:00
2017-10-17 23:49:24 +02:00
```
2017-10-17 23:48:02 +02:00
dotnet electronize init
2017-10-17 23:49:24 +02:00
```
2017-10-17 23:48:02 +02:00
* Now a electronnet.manifest.json should appear in your ASP.NET Core project
* Now run the following:
2017-10-18 22:58:01 +02:00
```
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](https://github.com/GregorBiswanger/Electron.NET/tree/master/ElectronNET.WebApp)
## Build
Here you need the Electron.NET CLI too. Type following command in your ASP.NET Core folder:
2017-10-17 23:49:44 +02:00
```
2017-10-17 23:48:02 +02:00
dotnet electronize build
2017-10-17 23:49:44 +02:00
```
2017-10-18 22:58:01 +02:00
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:
2017-10-17 23:48:02 +02:00
2017-10-17 23:49:24 +02:00
```
2017-10-17 23:48:02 +02:00
dotnet electronize build win
dotnet electronize build osx
dotnet electronize build linux
2017-10-17 23:49:24 +02:00
```
2017-10-17 23:48:02 +02:00
2017-10-18 22:58:01 +02:00
The end result should be an electron app under your __/bin/desktop__ folder.
### Note
> An OS X App can only be built on a host OS X platform.
2017-10-17 23:48:02 +02:00
# Contributing
Feel free to submit a pull request if you find any bugs (to see a list of active issues, visit the [Issues section](https://github.com/ElectronNET/Electron.NET/issues).
Please make sure all commits are properly documented.
2017-10-03 23:37:46 +02:00
# Authors
2017-10-03 23:37:46 +02:00
* **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](http://www.cross-platform-blog.com) - Twitter [@BFreakout](https://www.twitter.com/BFreakout)
* **Robert Muehsig** - Software Developer - from Dresden, Germany, now living & working in Switzerland. Microsoft MVP & Web Geek. - [codeinside Blog](https://blog.codeinside.eu) - Twitter [@robert0muehsig](https://twitter.com/robert0muehsig)
See also the list of [contributors](https://github.com/ElectronNET/Electron.NET/graphs/contributors) who participated in this project.
# License
MIT-licensed
2017-10-03 23:37:46 +02:00
2017-10-24 22:29:13 +02:00
**Enjoy!**