diff --git a/Changelog.md b/Changelog.md index a45094a1..107f8797 100644 --- a/Changelog.md +++ b/Changelog.md @@ -7,6 +7,7 @@ - Improved migration checks to honor custom output paths and to detect `ProjectGuid` in publish profiles (#946) - Fixed single instance handling on macOS (#1040) - Fixed slow socket bridge startup by binding to an explicit loopback address (#1103) +- Fixed local debugging launching the host `main.js` as a script file, which made Electron run its default app and resolve app name and userData to "Electron" instead of the app's `productName` (dev launch now points at the `.electron` app directory) - Fixed socket bridge connection when a system proxy is configured (#1105) - Fixed electron-builder using the host RID instead of the target RID (#1097) - Fixed cross-compilation behavior on same platform (#1098) @epsnm diff --git a/docs/Using/Debugging.md b/docs/Using/Debugging.md index 3c7f5c42..20e3d83d 100644 --- a/docs/Using/Debugging.md +++ b/docs/Using/Debugging.md @@ -40,7 +40,7 @@ Debug the Electron process when you need to inspect native Electron APIs: "Electron (unpackaged)": { "commandName": "Executable", "executablePath": "node", - "commandLineArgs": "node_modules/electron/cli.js main.js -unpackedelectron", + "commandLineArgs": "node_modules/electron/cli.js . -unpackedelectron", "workingDirectory": "$(TargetDir).electron", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" @@ -99,7 +99,7 @@ Add the debugging profiles to `Properties/launchSettings.json`: "Electron (unpackaged)": { "commandName": "Executable", "executablePath": "node", - "commandLineArgs": "node_modules/electron/cli.js main.js -unpackedelectron", + "commandLineArgs": "node_modules/electron/cli.js . -unpackedelectron", "workingDirectory": "$(TargetDir).electron", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" diff --git a/docs/Using/Startup-Methods.md b/docs/Using/Startup-Methods.md index 1c684839..c64c5d9a 100644 --- a/docs/Using/Startup-Methods.md +++ b/docs/Using/Startup-Methods.md @@ -17,7 +17,9 @@ The framework supports **8 different launch scenarios** covering every combinati #### **`-unpackedelectron`** - Electron-first debugging ```bash # Launch Electron first, which then starts .NET -node node_modules/electron/cli.js main.js -unpackedelectron +# ('.' = the .electron dir: Electron then reads its package.json as the app manifest, +# so the app name and userData folder resolve correctly instead of defaulting to "Electron") +node node_modules/electron/cli.js . -unpackedelectron ``` #### **`-unpackeddotnet`** - .NET-first debugging @@ -146,7 +148,7 @@ The image above illustrates how each combination of deployment type, application "Electron (unpackaged)": { "commandName": "Executable", "executablePath": "node", - "commandLineArgs": "node_modules/electron/cli.js main.js -unpackedelectron" + "commandLineArgs": "node_modules/electron/cli.js . -unpackedelectron" } } ``` diff --git a/src/ElectronNET.API/Runtime/Services/ElectronProcess/ElectronProcessActive.cs b/src/ElectronNET.API/Runtime/Services/ElectronProcess/ElectronProcessActive.cs index 55e502d0..a0ed5f4b 100644 --- a/src/ElectronNET.API/Runtime/Services/ElectronProcess/ElectronProcessActive.cs +++ b/src/ElectronNET.API/Runtime/Services/ElectronProcess/ElectronProcessActive.cs @@ -83,7 +83,10 @@ protected override async Task StartCore() startCmd = Path.Combine(electrondir, "node_modules", "electron", "dist", "Electron.app", "Contents", "MacOS", "Electron"); } - args = $"main.js -unpackeddotnet --trace-warnings -electronforcedport={this.socketPort:D} " + this.extraArguments; + // Pass the .electron directory instead of the main.js script file: with a script + // file Electron falls back to its default app, whose manifest is named "Electron", + // so the default userData folder becomes %APPDATA%\Electron from process startup. + args = $". -unpackeddotnet --trace-warnings -electronforcedport={this.socketPort:D} " + this.extraArguments; workingDir = electrondir; } else diff --git a/src/ElectronNET.ConsoleApp/Properties/launchSettings.json b/src/ElectronNET.ConsoleApp/Properties/launchSettings.json index 5eed0b9f..b431b420 100644 --- a/src/ElectronNET.ConsoleApp/Properties/launchSettings.json +++ b/src/ElectronNET.ConsoleApp/Properties/launchSettings.json @@ -9,7 +9,7 @@ "Electron (unpackaged)": { "commandName": "Executable", "executablePath": "node", - "commandLineArgs": "node_modules/electron/cli.js main.js -unpackedelectron", + "commandLineArgs": "node_modules/electron/cli.js . -unpackedelectron", "workingDirectory": "$(TargetDir).electron", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" diff --git a/src/ElectronNET.WebApp/Properties/launchSettings.json b/src/ElectronNET.WebApp/Properties/launchSettings.json index 2cd3aa83..1735382b 100644 --- a/src/ElectronNET.WebApp/Properties/launchSettings.json +++ b/src/ElectronNET.WebApp/Properties/launchSettings.json @@ -10,7 +10,7 @@ "Electron (unpackaged)": { "commandName": "Executable", "executablePath": "node", - "commandLineArgs": "node_modules/electron/cli.js main.js -unpackedelectron", + "commandLineArgs": "node_modules/electron/cli.js . -unpackedelectron", "workingDirectory": "$(TargetDir).electron", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development"