migrate from .net core 1.1 to 2.0

This commit is contained in:
Gregor Biswanger
2017-10-03 04:17:14 +02:00
parent 852d3c170d
commit a0a3e6fc15
8 changed files with 52 additions and 31 deletions

View File

@@ -12,7 +12,7 @@ namespace ElectronNET.API
private readonly Socket _socket;
private readonly JsonSerializer _jsonSerializer;
public App(int width, int height)
public App(int width, int height, bool show)
{
_jsonSerializer = new JsonSerializer()
{
@@ -26,7 +26,8 @@ namespace ElectronNET.API
var browserWindowOptions = new BrowserWindowOptions() {
Height = height,
Width = width
Width = width,
Show = show
};
socket.Emit("createBrowserWindow", JObject.FromObject(browserWindowOptions, _jsonSerializer));

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

13
ElectronNET.Host/.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,13 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Electron App",
"cwd": "${workspaceRoot}",
"runtimeExecutable": "${workspaceRoot}\\node_modules\\.bin\\electron.cmd",
"program": "${workspaceRoot}\\main.js"
}
]
}

View File

@@ -1,19 +1,36 @@
// const { app, BrowserWindow } = require('electron');
const { app, BrowserWindow } = require('electron');
const io = require('socket.io')(3000);
const path = require('path');
// let window;
let window;
let apiProcess;
// app.on('ready', () => {
app.on('ready', () => {
const process = require('child_process').spawn;
// run server
var apipath = path.join(__dirname, '..\\ElectronNET.WebApp\\bin\\dist\\win\\ElectronNET.WebApp.exe');
apiProcess = process(apipath);
// });
apiProcess.stdout.on('data', (data) => {
console.log(`stdout: ${data}`);
});
});
io.on('connection', (socket) => {
console.log('a user connected');
socket.on('createBrowserWindow', (options) => {
console.log(options);
options.show = true;
window = new BrowserWindow(options);
window.loadURL('http://localhost:5000');
window.on('closed', function () {
mainWindow = null;
apiProcess = null;
});
});
});

View File

@@ -2,7 +2,7 @@
"name": "ElectronNET.Host",
"version": "1.0.0",
"description": "",
"main": "index.js",
"main": "main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},

View File

@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<TargetFramework>netcoreapp2.0</TargetFramework>
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
</PropertyGroup>
<ItemGroup>
@@ -9,8 +10,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore" Version="2.0.0" />
</ItemGroup>
<ItemGroup>

View File

@@ -1,13 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using System.Net.Sockets;
using System.Net;
using System.Text;
using System.Diagnostics;
namespace ElectronNET.WebApp
{
@@ -15,15 +7,12 @@ namespace ElectronNET.WebApp
{
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.UseApplicationInsights()
.Build();
host.Run();
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();
}
}

View File

@@ -13,6 +13,7 @@ namespace ElectronNET.WebApp
// 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.
@@ -30,7 +31,7 @@ namespace ElectronNET.WebApp
await context.Response.WriteAsync("Hello World!");
});
var electronApp = new App(800, 600);
var electronApp = new App(800, 600, true);
}
}
}