Summary
- Version: ElectronNET.Core / ElectronNET.Core.AspNet 0.5.0
- .NET: .NET 10 (net10.0)
- Electron: 39.8.9
- Target: win-x64 also macOS/Linux packaged targets
In a packaged app, the first user argument is dropped before being forwarded
to the backend, because the host main.js uses process.argv.slice(2):
return process.argv.slice(2).filter(arg => { ... });
The first user argument shifts by one between launch modes (offset documented
in #647), so the fixed slice(2) only matches the dev launch:
electronize start (dev): first user arg at process.argv[2] -> slice(2) keeps it ✓
packaged executable: first user arg at process.argv[1] -> slice(2) drops it ✗
Steps to Reproduce
- Run
myapp.exe --foo=bar — backend gets no args.
- Run
myapp.exe -- --foo=bar — --foo=bar arrives, confirming the first argument is swallowed.
Fix
const argsOffset = app.isPackaged ? 1 : 2;
return process.argv.slice(argsOffset).filter(arg => { ... });
Workaround
Insert an empty argument -- before getForwardedArgs() runs, via the custom_main.js hook:
const { app } = require('electron');
exports.onStartup = function () {
if (app.isPackaged) {
process.argv.splice(1, 0, '--');
}
return true;
};
Summary
In a packaged app, the first user argument is dropped before being forwarded
to the backend, because the host
main.jsusesprocess.argv.slice(2):The first user argument shifts by one between launch modes (offset documented
in #647), so the fixed
slice(2)only matches the dev launch:Steps to Reproduce
myapp.exe --foo=bar— backend gets no args.myapp.exe -- --foo=bar—--foo=bararrives, confirming the first argument is swallowed.Fix
Workaround
Insert an empty argument
--beforegetForwardedArgs()runs, via thecustom_main.jshook: