Repository navigation
fix: dev launches passing the script file instead of the app directory - #1121
Merged
FlorianRappl merged 1 commit intoOct 22, 2026
Merged
FlorianRappl merged 1 commit into
FlorianRappl merged 1 commit into
Conversation
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).
pr-comment: Run #154
🎉 All tests passed!Github Test Reporter by CTRF 💚 |
FlorianRappl
approved these changes
Oct 22, 2026
FlorianRappl
left a comment
Collaborator
There was a problem hiding this comment.
LGTM - let's get the preview out.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
In unpackaged (dev) launches, Electron was started with
main.jsas its firstargument. Because that is a script file and not an app directory, Electron
routed through its built-in default app (
default_app.asar), whose manifest isnamed
Electron. As a result, the app name and the defaultuserDatafolderwere resolved by Chromium at process startup to:
This happens inside the Chromium layer long before
app.on('ready')— soGPU cache, network-service storage, etc. are created under that path at
startup, and any later correction (e.g. via
app.setPathonready) ispartial and leaves a stray
%APPDATA%\Electronfolder behind on every run.The generated
.electron/package.json(built byElectronCreatePackageJsonfrom the template + MSBuild props) already contains the correct
name/productName— it just was never submitted to Electron as the appmanifest. It was only read as data by
main.js; the process was pointed atthe script file instead of the directory.
Changes
ElectronProcessActive.cs(unpackaged/.NET-first branch): launchelectron <.electron dir>instead ofelectron main.js, so Electron readspackage.jsonas the app manifest and resolves app name + defaultuserDatafromproductNameat startup — same mechanism as a packagedbuild. Covers the Windows and macOS (
Electron.app/Contents/MacOS/Electron)launch paths.
launchSettings.json/ docs: the "Electron-first" debug profiles and docssnippets now also pass the app directory (
.) instead ofmain.js.Compatibility notes
main.jsderives all paths (currentPath, manifest,currentBinPath) from__dirname, which is unchanged when the directory is the app argument.app.isPackagedstaysfalsewith an unpackaged directory app, sogetForwardedArgs()(process.argv.slice(app.isPackaged ? 1 : 2)) and thecommand-line switch handling are unaffected.
Testing
dotnet run -unpackeddotnet(sample app, Windows): launched processcommand line is
...electron.exe . -unpackeddotnet --trace-warnings -electronforcedport=...--user-data-dir=%APPDATA%\<productName>; no%APPDATA%\Electronfolder is created on dev runs (previously it reappeared every launch)
verified)