auto detect of asp.core exe file

This commit is contained in:
Gregor Biswanger
2017-10-06 03:27:16 +02:00
parent 383e9cd3fa
commit d3fc1c8657
2 changed files with 28 additions and 8 deletions

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

@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Electron App",
"program": "${workspaceFolder}\\main.js",
"runtimeExecutable": "${workspaceFolder}\\node_modules\\.bin\\electron"
}
]
}

View File

@@ -1,22 +1,27 @@
const { app, BrowserWindow, Notification } = require('electron');
const io = require('socket.io')(3000);
const fs = require('fs');
const path = require('path');
const process = require('child_process').spawn;
let window;
let apiProcess;
app.on('ready', () => {
const process = require('child_process').spawn;
// run server
// ToDo: The .exe name may vary. The most simple solution would be to locate the first .exe in the given directory
var apipath = path.join(__dirname, '\\bin\\ElectronNET.WebApp.exe');
apiProcess = process(apipath);
var binPath = path.join(__dirname, 'bin');
fs.readdir(binPath, (error, files) => {
const exeFiles = files.filter((name) => name.indexOf('.exe') > -1);
const exeFileName = exeFiles[0];
const apipath = path.join(binPath, exeFileName);
apiProcess = process(apipath);
apiProcess.stdout.on('data', (data) => {
var text = data.toString();
console.log(`stdout: ${data.toString()}`);
apiProcess.stdout.on('data', (data) => {
var text = data.toString();
console.log(`stdout: ${data.toString()}`);
});
});
});
io.on('connection', (socket) => {