diff --git a/ElectronNET.CLI/ElectronHost/main.js b/ElectronNET.CLI/ElectronHost/main.js index 9d28157..738ff02 100644 --- a/ElectronNET.CLI/ElectronHost/main.js +++ b/ElectronNET.CLI/ElectronHost/main.js @@ -9,7 +9,8 @@ app.on('ready', () => { const process = require('child_process').spawn; // run server - var apipath = path.join(__dirname, '\\bin\\ElectronNET.WebApp.exe'); + // 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 /electronized=true'); apiProcess = process(apipath); apiProcess.stdout.on('data', (data) => { diff --git a/ElectronNET.WebApp/Program.cs b/ElectronNET.WebApp/Program.cs index d3e863d..d7b6ca0 100644 --- a/ElectronNET.WebApp/Program.cs +++ b/ElectronNET.WebApp/Program.cs @@ -1,6 +1,7 @@ using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using System; +using System.Diagnostics; namespace ElectronNET.WebApp { @@ -13,10 +14,38 @@ namespace ElectronNET.WebApp // WICHTIG! UseContentRoot auf Assembly Ordner Essentiell! // Ggf. kann man via Parameter den Content Root durchreichen? - public static IWebHost BuildWebHost(string[] args) => - WebHost.CreateDefaultBuilder(args) - .UseContentRoot(AppDomain.CurrentDomain.BaseDirectory) - .UseStartup() - .Build(); + public static IWebHost BuildWebHost(string[] args) + { + // ToDo: Maybe add a "electronized" args check here? + // this is the electron case! + if (args.Length > 0) + { + Console.WriteLine("Test Switch for Electron detection: " + args[0]); + return WebHost.CreateDefaultBuilder(args) + .UseContentRoot(AppDomain.CurrentDomain.BaseDirectory) + .UseStartup() + .Build(); + } + else + { + return WebHost.CreateDefaultBuilder(args) + .UseStartup() + .Build(); + } + + // this didn't work... its too late, idk... + //var builder = WebHost.CreateDefaultBuilder(args); + + //if (args.Length > 0) + //{ + // // ToDo: Maybe add a "electronized" args check here? + // Console.WriteLine("Test Switch for Electron detection: " + args[0]); + // builder = builder.UseContentRoot(AppDomain.CurrentDomain.BaseDirectory); + //} + + //builder = builder.UseStartup(); + + //return builder.Build(); + } } }