Skip to content

exe does not automatically exit when run from a Windows command prompt #888

@icnocop

Description

@icnocop
  • Target: .net 8, Node.js v20.19.0, running on Windows 10 x64

Steps to Reproduce:

  1. Clone the main branch https://github.com/ElectronNET/Electron.NET.git
  2. Open ElectronNET.sln in Visual Studio 2022 and Build in the Debug | Any CPU solution configuration.
  3. Open a new Windows Command Prompt
  4. Run cd .\src\ElectronNET.WebApp
  5. Run "..\ElectronNET.CLI\bin\Debug\net8.0\dotnet-electronize.exe" build /target win /dotnet-configuration Debug /p:SelfContained=false /p:BuildProjectReferences=false
  6. Run cd .\src\ElectronNET.WebApp\bin\Desktop\win-unpacked
  7. Run "ElectronNET API Demos.exe"
  8. Close the "ElectronNET API Demo" window
  9. Notice the process is still running and I have to press Ctrl+C to close the process.

The issue also occurs if I try to exit the program even before calling Electron.WindowManager.CreateWindowAsync.

I expected the process to exit when all windows are closed, since Electron.WindowManager.IsQuitOnWindowAllClosed is set to true by default.

If I double-click the exe from Windows Explorer, the issue doesn't occur.

As other issues mention, I even tried:

Electron.WindowManager.IsQuitOnWindowAllClosed = false;
Electron.App.WindowAllClosed += () => Electron.App.Exit();

browserWindow.OnClosed += () =>
{
    Electron.App.Exit(0);
    Environment.Exit(0);
    Electron.App.Quit();
};

Seems related, but the issues are closed, and don't mention running on the command line:
#68
#226
#338
#346
#364
#594

Image

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions