Electronize Build Argument Parsing #604

Open
opened 2026-01-29 16:43:55 +00:00 by claunia · 0 comments
Owner

Originally created by @EnsignPayton on GitHub (Dec 1, 2020).

Originally assigned to: @GregorBiswanger on GitHub.

  • Version:

ElectronNET.API: 9.31.2
ElectronNET.CLI: 9.31.2
.NET: 5.0.100
Node.js: 12.16.2

  • Target: win

Steps to Reproduce:

  1. Run electronize build /target win
  2. Argument parsing fails

I followed this guide for setting up a Blazor server project hosed in Electron: https://blog.jetbrains.com/dotnet/2020/11/05/run-blazor-apps-within-electron-shell/

It works great in debug, but electronize build won't do anything at all. Any calls to electronize build or dotnet electronize build fail with the following message:

$ electronize build /target win
Build Electron Application...
Error: missing 'target' argument.
Needed: '/target' with params 'win/osx/linux' to build for a typical app or use 'custom' and specify .NET Core build config & electron build config
 for custom target, check .NET Core RID Catalog and Electron build target/
 e.g. '/target win' or '/target custom "win7-x86;win32"'
Optional: '/dotnet-configuration' with the desired .NET Core build config e.g. release or debug. Default = Release
Optional: '/electron-arch' to specify the resulting electron processor architecture (e.g. ia86 for x86 builds). Be aware to use the '/target custom' param as well!
Optional: '/electron-params' specify any other valid parameter, which will be routed to the electron-packager.
Optional: '/relative-path' to specify output a subdirectory for output.
Optional: '/absolute-path to specify and absolute path for output.
Optional: '/package-json' to specify a custom package.json file.
Optional: '/install-modules' to force node module install. Implied by '/package-json'
Full example for a 32bit debug build with electron prune: build /target custom win7-x86;win32 /dotnet-configuration Debug /electron-arch ia32  /electron-params "--prune=true "

The only way I can get around this is by passing in a literal target argument with no leading slash, which causes an exception:

$ electronize build target win
Build Electron Application...
Unhandled exception. System.AggregateException: One or more errors occurred. (Index was outside the bounds of the array.)
 ---> System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at ElectronNET.CLI.Commands.BuildCommand.<ExecuteAsync>b__19_0() in C:\_WorkRepos\Electron.NET\ElectronNET.CLI\Commands\BuildCommand.cs:line 50
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.<>c.<.cctor>b__274_0(Object obj)
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at System.Threading.Tasks.Task`1.get_Result()
   at ElectronNET.CLI.Program.Main(String[] args) in C:\_WorkRepos\Electron.NET\ElectronNET.CLI\Program.cs:line 59
Originally created by @EnsignPayton on GitHub (Dec 1, 2020). Originally assigned to: @GregorBiswanger on GitHub. <!-- Please search existing issues to avoid creating duplicates. --> <!-- Which version of Electron.NET CLI and API are you using? --> <!-- Please always try to use latest version before report. --> * **Version**: ElectronNET.API: 9.31.2 ElectronNET.CLI: 9.31.2 .NET: 5.0.100 Node.js: 12.16.2 <!-- Which version of .NET Core and Node.js are you using (if applicable)? --> <!-- What target are you building for? --> * **Target**: win <!-- Enter your issue details below this comment. --> <!-- If you want, you can donate to increase issue priority (https://donorbox.org/electron-net) --> Steps to Reproduce: 1. Run `electronize build /target win` 2. Argument parsing fails I followed this guide for setting up a Blazor server project hosed in Electron: https://blog.jetbrains.com/dotnet/2020/11/05/run-blazor-apps-within-electron-shell/ It works great in debug, but `electronize build` won't do anything at all. Any calls to `electronize build` or `dotnet electronize build` fail with the following message: ``` $ electronize build /target win Build Electron Application... Error: missing 'target' argument. Needed: '/target' with params 'win/osx/linux' to build for a typical app or use 'custom' and specify .NET Core build config & electron build config for custom target, check .NET Core RID Catalog and Electron build target/ e.g. '/target win' or '/target custom "win7-x86;win32"' Optional: '/dotnet-configuration' with the desired .NET Core build config e.g. release or debug. Default = Release Optional: '/electron-arch' to specify the resulting electron processor architecture (e.g. ia86 for x86 builds). Be aware to use the '/target custom' param as well! Optional: '/electron-params' specify any other valid parameter, which will be routed to the electron-packager. Optional: '/relative-path' to specify output a subdirectory for output. Optional: '/absolute-path to specify and absolute path for output. Optional: '/package-json' to specify a custom package.json file. Optional: '/install-modules' to force node module install. Implied by '/package-json' Full example for a 32bit debug build with electron prune: build /target custom win7-x86;win32 /dotnet-configuration Debug /electron-arch ia32 /electron-params "--prune=true " ``` The only way I can get around this is by passing in a literal `target` argument with no leading slash, which causes an exception: ``` $ electronize build target win Build Electron Application... Unhandled exception. System.AggregateException: One or more errors occurred. (Index was outside the bounds of the array.) ---> System.IndexOutOfRangeException: Index was outside the bounds of the array. at ElectronNET.CLI.Commands.BuildCommand.<ExecuteAsync>b__19_0() in C:\_WorkRepos\Electron.NET\ElectronNET.CLI\Commands\BuildCommand.cs:line 50 at System.Threading.Tasks.Task`1.InnerInvoke() at System.Threading.Tasks.Task.<>c.<.cctor>b__274_0(Object obj) at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location where exception was thrown --- at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification) at System.Threading.Tasks.Task`1.get_Result() at ElectronNET.CLI.Program.Main(String[] args) in C:\_WorkRepos\Electron.NET\ElectronNET.CLI\Program.cs:line 59 ```
claunia added the bug label 2026-01-29 16:43:55 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#604