diff --git a/ElectronNET.API/IpcMain.cs b/ElectronNET.API/IpcMain.cs
index 1508078..eae3f3c 100644
--- a/ElectronNET.API/IpcMain.cs
+++ b/ElectronNET.API/IpcMain.cs
@@ -207,6 +207,27 @@ namespace ElectronNET.API
}
}
+ ///
+ /// Log a message to the console output pipe. This is used when running with "detachedProcess" : true on the electron.manifest.json,
+ /// as in that case we can't open pipes to read the console output from the child process anymore
+ ///
+ /// Message to log
+ public static void ConsoleLog(string text)
+ {
+ BridgeConnector.Emit("console-stdout", text);
+ }
+
+ ///
+ /// Log a message to the console error pipe. This is used when running with "detachedProcess" : true on the electron.manifest.json,
+ /// as in that case we can't open pipes to read the console output from the child process anymore
+ ///
+ /// Message to log
+
+ public static void ConsoleError(string text)
+ {
+ BridgeConnector.Emit("console-stderr", text);
+ }
+
private JsonSerializer _jsonSerializer = new JsonSerializer()
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
diff --git a/ElectronNET.Host/main.js b/ElectronNET.Host/main.js
index b3bcd69..862871b 100644
--- a/ElectronNET.Host/main.js
+++ b/ElectronNET.Host/main.js
@@ -271,6 +271,14 @@ function startSocketApiBridge(port) {
}
});
+ socket.on('console-stdout', (data) => {
+ console.log(`stdout: ${data.toString()}`);
+ });
+
+ socket.on('console-stderr', (data) => {
+ console.log(`stderr: ${data.toString()}`);
+ });
+
try {
const hostHookScriptFilePath = path.join(__dirname, 'ElectronHostHook', 'index.js');
@@ -320,7 +328,7 @@ function startAspCoreBackend(electronPort) {
if (manifestJsonFile.hasOwnProperty('detachedProcess')) {
detachedProcess = manifestJsonFile.detachedProcess;
if (detachedProcess) {
- stdioopt = ['ignore', 'pipe', 'pipe'];
+ stdioopt = 'ignore';
}
}
@@ -376,7 +384,7 @@ function startAspCoreBackendWithWatch(electronPort) {
if (manifestJsonFile.hasOwnProperty('detachedProcess')) {
detachedProcess = manifestJsonFile.detachedProcess;
if (detachedProcess) {
- stdioopt = ['ignore', 'pipe', 'pipe'];
+ stdioopt = 'ignore';
}
}