Skip to content

Commit 905e1bb

Browse files
authored
Merge pull request #1121 from Denny09310/feature/fix-dev-userdata-appname
fix: dev launches passing the script file instead of the app directory
2 parents 2ec2292 + 255e3cf commit 905e1bb

6 files changed

Lines changed: 13 additions & 7 deletions

File tree

‎Changelog.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- Improved migration checks to honor custom output paths and to detect `ProjectGuid` in publish profiles (#946)
88
- Fixed single instance handling on macOS (#1040)
99
- Fixed slow socket bridge startup by binding to an explicit loopback address (#1103)
10+
- 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)
1011
- Fixed socket bridge connection when a system proxy is configured (#1105)
1112
- Fixed electron-builder using the host RID instead of the target RID (#1097)
1213
- Fixed cross-compilation behavior on same platform (#1098) @epsnm

‎docs/Using/Debugging.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Debug the Electron process when you need to inspect native Electron APIs:
4040
"Electron (unpackaged)": {
4141
"commandName": "Executable",
4242
"executablePath": "node",
43-
"commandLineArgs": "node_modules/electron/cli.js main.js -unpackedelectron",
43+
"commandLineArgs": "node_modules/electron/cli.js . -unpackedelectron",
4444
"workingDirectory": "$(TargetDir).electron",
4545
"environmentVariables": {
4646
"ASPNETCORE_ENVIRONMENT": "Development"
@@ -99,7 +99,7 @@ Add the debugging profiles to `Properties/launchSettings.json`:
9999
"Electron (unpackaged)": {
100100
"commandName": "Executable",
101101
"executablePath": "node",
102-
"commandLineArgs": "node_modules/electron/cli.js main.js -unpackedelectron",
102+
"commandLineArgs": "node_modules/electron/cli.js . -unpackedelectron",
103103
"workingDirectory": "$(TargetDir).electron",
104104
"environmentVariables": {
105105
"ASPNETCORE_ENVIRONMENT": "Development"

‎docs/Using/Startup-Methods.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ The framework supports **8 different launch scenarios** covering every combinati
1717
#### **`-unpackedelectron`** - Electron-first debugging
1818
```bash
1919
# Launch Electron first, which then starts .NET
20-
node node_modules/electron/cli.js main.js -unpackedelectron
20+
# ('.' = the .electron dir: Electron then reads its package.json as the app manifest,
21+
# so the app name and userData folder resolve correctly instead of defaulting to "Electron")
22+
node node_modules/electron/cli.js . -unpackedelectron
2123
```
2224

2325
#### **`-unpackeddotnet`** - .NET-first debugging
@@ -146,7 +148,7 @@ The image above illustrates how each combination of deployment type, application
146148
"Electron (unpackaged)": {
147149
"commandName": "Executable",
148150
"executablePath": "node",
149-
"commandLineArgs": "node_modules/electron/cli.js main.js -unpackedelectron"
151+
"commandLineArgs": "node_modules/electron/cli.js . -unpackedelectron"
150152
}
151153
}
152154
```

‎src/ElectronNET.API/Runtime/Services/ElectronProcess/ElectronProcessActive.cs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ protected override async Task StartCore()
8383
startCmd = Path.Combine(electrondir, "node_modules", "electron", "dist", "Electron.app", "Contents", "MacOS", "Electron");
8484
}
8585

86-
args = $"main.js -unpackeddotnet --trace-warnings -electronforcedport={this.socketPort:D} " + this.extraArguments;
86+
// Pass the .electron directory instead of the main.js script file: with a script
87+
// file Electron falls back to its default app, whose manifest is named "Electron",
88+
// so the default userData folder becomes %APPDATA%\Electron from process startup.
89+
args = $". -unpackeddotnet --trace-warnings -electronforcedport={this.socketPort:D} " + this.extraArguments;
8790
workingDir = electrondir;
8891
}
8992
else

‎src/ElectronNET.ConsoleApp/Properties/launchSettings.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"Electron (unpackaged)": {
1010
"commandName": "Executable",
1111
"executablePath": "node",
12-
"commandLineArgs": "node_modules/electron/cli.js main.js -unpackedelectron",
12+
"commandLineArgs": "node_modules/electron/cli.js . -unpackedelectron",
1313
"workingDirectory": "$(TargetDir).electron",
1414
"environmentVariables": {
1515
"ASPNETCORE_ENVIRONMENT": "Development"

‎src/ElectronNET.WebApp/Properties/launchSettings.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"Electron (unpackaged)": {
1111
"commandName": "Executable",
1212
"executablePath": "node",
13-
"commandLineArgs": "node_modules/electron/cli.js main.js -unpackedelectron",
13+
"commandLineArgs": "node_modules/electron/cli.js . -unpackedelectron",
1414
"workingDirectory": "$(TargetDir).electron",
1515
"environmentVariables": {
1616
"ASPNETCORE_ENVIRONMENT": "Development"

0 commit comments

Comments
 (0)