Fix dev launches passing the script file instead of the app directory

Point the unpackaged dev launches at the .electron directory rather than
main.js, so Electron reads package.json as the app manifest and resolves
the app name and the default userData folder from productName at process
startup, instead of falling back to the default app's "Electron" name.
Covers the .NET-first branch in ElectronProcessActive and the
Electron-first launches (launchSettings and docs).
This commit is contained in:
Denny09310
2026-10-22 08:42:04 +02:00
parent 2ec22921bd
commit 255e3cf50f
6 changed files with 13 additions and 7 deletions

View File

@@ -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

View File

@@ -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"

View File

@@ -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"
}
}
```

View File

@@ -83,7 +83,10 @@
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

View File

@@ -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"

View File

@@ -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"