From 029b0776028316c510c8f846d9f567b2c0ca5b9e Mon Sep 17 00:00:00 2001 From: Gregor Biswanger Date: Tue, 26 May 2020 22:03:05 +0200 Subject: [PATCH] manage the configuration environment with the electron.manifest.json --- Changelog.md | 2 ++ ElectronNET.CLI/Commands/BuildCommand.cs | 3 +-- ElectronNET.CLI/Commands/StartElectronCommand.cs | 6 ++---- ElectronNET.Host/electron.manifest.json | 5 +++-- ElectronNET.Host/main.js | 12 ++++++++++-- ElectronNET.WebApp/electron.manifest.json | 1 + 6 files changed, 19 insertions(+), 10 deletions(-) diff --git a/Changelog.md b/Changelog.md index d62f1f9..9deff90 100644 --- a/Changelog.md +++ b/Changelog.md @@ -5,6 +5,7 @@ ElectronNET.CLI: * New Feature: Added config parameter (thanks [konstantingross](https://github.com/konstantingross)) [\#409](https://github.com/ElectronNET/Electron.NET/pull/409) +* New Feature: Set the configuration environment with the electron.manifest.json file. * Fixed bug: Custom user path removed and replaced by the correct directory with VS macro (When ElectronNET.CLI is the Startup Project, press F5 (Debug) and the ElectronNET.WebApp starts correctly without error!) (thanks [konstantingross](https://github.com/konstantingross)) [\#409](https://github.com/ElectronNET/Electron.NET/pull/409) ElectronNET.API: @@ -16,6 +17,7 @@ ElectronNET.API: * App-Api Enhancement: MenuItems with Submenus need an submenu type workaround [\#412](https://github.com/ElectronNET/Electron.NET/issues/412) * App-Api Enhancement: Added UserAgentFallback (thanks [Mandrakia](https://github.com/Mandrakia)) [\#406](https://github.com/ElectronNET/Electron.NET/pull/406) * App-Api Enhancement: New App.IsReady property and App.Ready event (thanks [konstantingross](https://github.com/konstantingross)) [\#415](https://github.com/ElectronNET/Electron.NET/pull/415) +* Shell-Api Enhancement: Shell.OpenItem API fix for Electron 9.0.0 (thanks [konstantingross](https://github.com/konstantingross)) [\#417](https://github.com/ElectronNET/Electron.NET/pull/417) * Notification-Api Enhancement: Added missing properties in Notifications (thanks [konstantingross](https://github.com/konstantingross)) [\#410](https://github.com/ElectronNET/Electron.NET/pull/410) * BrowserWindows-Api Enhancement: Add missing API call for SetProgressBar options (thanks [konstantingross](https://github.com/konstantingross)) [\#416](https://github.com/ElectronNET/Electron.NET/pull/416) * MacOS Enhancement: Application exit logic (thanks [dafergu2](https://github.com/dafergu2)) [\#405](https://github.com/ElectronNET/Electron.NET/pull/405) diff --git a/ElectronNET.CLI/Commands/BuildCommand.cs b/ElectronNET.CLI/Commands/BuildCommand.cs index 50ed119..26ac6b9 100644 --- a/ElectronNET.CLI/Commands/BuildCommand.cs +++ b/ElectronNET.CLI/Commands/BuildCommand.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Runtime.InteropServices; using System.Threading.Tasks; using ElectronNET.CLI.Commands.Actions; @@ -106,7 +105,7 @@ namespace ElectronNET.CLI.Commands publishReadyToRun += "true"; } - var resultCode = ProcessHelper.CmdExecute($"dotnet publish -r {platformInfo.NetCorePublishRid} -c {configuration} --output \"{tempBinPath}\" {publishReadyToRun} --self-contained", Directory.GetCurrentDirectory()); + var resultCode = ProcessHelper.CmdExecute($"dotnet publish -r {platformInfo.NetCorePublishRid} -c \"{configuration}\" --output \"{tempBinPath}\" {publishReadyToRun} --self-contained", Directory.GetCurrentDirectory()); if (resultCode != 0) { diff --git a/ElectronNET.CLI/Commands/StartElectronCommand.cs b/ElectronNET.CLI/Commands/StartElectronCommand.cs index 64c0f8b..565af41 100644 --- a/ElectronNET.CLI/Commands/StartElectronCommand.cs +++ b/ElectronNET.CLI/Commands/StartElectronCommand.cs @@ -74,7 +74,7 @@ namespace ElectronNET.CLI.Commands publishReadyToRun += "true"; } - string configuration = "Release"; + string configuration = "Debug"; if (parser.Arguments.ContainsKey(_paramDotNetConfig)) { configuration = parser.Arguments[_paramDotNetConfig][0]; @@ -82,7 +82,7 @@ namespace ElectronNET.CLI.Commands if (parser != null && !parser.Arguments.ContainsKey("watch")) { - resultCode = ProcessHelper.CmdExecute($"dotnet publish -r {platformInfo.NetCorePublishRid} -c {configuration} --output \"{tempBinPath}\" {publishReadyToRun} --no-self-contained", aspCoreProjectPath); + resultCode = ProcessHelper.CmdExecute($"dotnet publish -r {platformInfo.NetCorePublishRid} -c \"{configuration}\" --output \"{tempBinPath}\" {publishReadyToRun} --no-self-contained", aspCoreProjectPath); } if (resultCode != 0) @@ -156,7 +156,5 @@ namespace ElectronNET.CLI.Commands return true; }); } - - } } diff --git a/ElectronNET.Host/electron.manifest.json b/ElectronNET.Host/electron.manifest.json index 1d9ce21..014fdec 100644 --- a/ElectronNET.Host/electron.manifest.json +++ b/ElectronNET.Host/electron.manifest.json @@ -6,6 +6,7 @@ "name": "{{executable}}", "author": "", "singleInstance": false, + "environment": "Production", "build": { "appId": "com.{{executable}}.app", "productName": "{{executable}}", @@ -19,14 +20,14 @@ { "from": "./bin", "to": "bin", - "filter": ["**/*"] + "filter": [ "**/*" ] } ], "files": [ { "from": "./ElectronHostHook/node_modules", "to": "ElectronHostHook/node_modules", - "filter": ["**/*"] + "filter": [ "**/*" ] }, "**/*" ] diff --git a/ElectronNET.Host/main.js b/ElectronNET.Host/main.js index 2db6bb1..066dda9 100644 --- a/ElectronNET.Host/main.js +++ b/ElectronNET.Host/main.js @@ -219,7 +219,7 @@ function startAspCoreBackend(electronPort) { function startBackend(aspCoreBackendPort) { console.log('ASP.NET Core Port: ' + aspCoreBackendPort); loadURL = `http://localhost:${aspCoreBackendPort}`; - const parameters = [`/electronPort=${electronPort}`, `/electronWebPort=${aspCoreBackendPort}`]; + const parameters = [getEnvironmentParameter(), `/electronPort=${electronPort}`, `/electronWebPort=${aspCoreBackendPort}`]; let binaryFile = manifestJsonFile.executable; const os = require('os'); @@ -250,7 +250,7 @@ function startAspCoreBackendWithWatch(electronPort) { function startBackend(aspCoreBackendPort) { console.log('ASP.NET Core Watch Port: ' + aspCoreBackendPort); loadURL = `http://localhost:${aspCoreBackendPort}`; - const parameters = ['watch', 'run', `/electronPort=${electronPort}`, `/electronWebPort=${aspCoreBackendPort}`]; + const parameters = ['watch', 'run', getEnvironmentParameter(), `/electronPort=${electronPort}`, `/electronWebPort=${aspCoreBackendPort}`]; var options = { cwd: currentBinPath, @@ -262,4 +262,12 @@ function startAspCoreBackendWithWatch(electronPort) { console.log(`stdout: ${data.toString()}`); }); } +} + +function getEnvironmentParameter() { + if(manifestJsonFile.environment) { + return '--environment=' + manifestJsonFile.environment; + } + + return ''; } \ No newline at end of file diff --git a/ElectronNET.WebApp/electron.manifest.json b/ElectronNET.WebApp/electron.manifest.json index c97f714..5e6ff0c 100644 --- a/ElectronNET.WebApp/electron.manifest.json +++ b/ElectronNET.WebApp/electron.manifest.json @@ -3,6 +3,7 @@ "splashscreen": { "imageFile": "/wwwroot/assets/img/about@2x.png" }, + "environment": "Production", "singleInstance": false, "build": { "appId": "com.electronnetapidemos.app",