[PR #648] [MERGED] Support launching app with file for win and linux #1241

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

📋 Pull Request Information

Original PR: https://github.com/ElectronNET/Electron.NET/pull/648
Author: @schaveyt
Created: 12/29/2021
Status: Merged
Merged: 4/6/2022
Merged by: @GregorBiswanger

Base: masterHead: feature/647-launching-app-w-file-win-linux


📝 Commits (7)

  • 8e1e184 #647 process argv for open-file for win and linux
  • 1406fc1 #647 add initial Process class to ElectronNET.API
  • 562cccb #647 add to ElectronNET.API Process member interfaces for argv and type
  • ba82b9a #647 add to ElectronNET.API Process member interfaces for various fields
  • 5921481 #647 correct to ElectronNET.API Process member for versions field
  • 24a2005 #647 update XML documentation to ElectronNET.API Process members
  • 64e058b #647 make ProcessVersions Entity a record to ensure readonly access to props

📊 Changes

11 files changed (+452 additions, -2 deletions)

View changed files

📝 ElectronNET.API/BridgeConnector.cs (+109 -1)
📝 ElectronNET.API/Electron.cs (+5 -0)
ElectronNET.API/Entities/ProcessVersions.cs (+10 -0)
ElectronNET.API/Process.cs (+185 -0)
📝 ElectronNET.API/ServiceCollectionExtensions.cs (+2 -1)
📝 ElectronNET.CLI/Commands/Actions/DeployEmbeddedElectronFiles.cs (+1 -0)
📝 ElectronNET.CLI/ElectronNET.CLI.csproj (+1 -0)
ElectronNET.Host/api/process.js (+62 -0)
ElectronNET.Host/api/process.js.map (+1 -0)
ElectronNET.Host/api/process.ts (+73 -0)
📝 ElectronNET.Host/main.js (+3 -0)

📄 Description

Status: Review Approved

Summary

Addresses #647 and remains compatible with existing behavior of passing arguments via /args commandline option.

This has been built and integration tested locally by invoking via electronize start as well as the compiled executable as described in the issue #647.

Change Summary

  1. Added the new Process class and singleton, this required:
    1. Updating ElectronNET.API/Electron.cs to add access to the Process singleton
    2. Updating ElectronNET.API/ServiceCollectionExtensions.cs to register Process singleton to the DI container
    3. Updating ElectronNET.CLI/Commands/Actions/DeployEmbeddedElectronFiles.cs to deploy the new embed the new .js file
    4. Updating ElectronNET.CLI/ElectronNET.CLI.csproj to embed the new process.js file to the CLI.
    5. Creating ElectronNET.Host/api/process.ts to interact with Electron's process object from the node side
    6. Creating ElectronNET.API/Process.cs to bridge with the electron api
    7. Updating ElectronNET.Host/main.js to initialize the processApi object.
  2. Updated ElectronNET.API/BridgeConnector.cs to add reusable methods to obtaining values over the Socket interface.
  3. Updated ElectronNET.API/Entities/ProcessVersion.cs as corresponding type to the electron.process.versions type.

Verification Summary

I was not able to get the WebApp project running however I was able to get my target project running with the update API & CLI changes. I created a simple test method as follows:

    public async void VerifyProcessApi()
    {      
        Console.WriteLine($"VerifyProcessApi START------------");
        Console.WriteLine($"Electron.Procsss.ExecPath='{await Electron.Process.ExecPathAsync}'");
        Console.WriteLine($"Electron.Procsss.TypeAsync='{await Electron.Process.TypeAsync}'");

        var argv = await Electron.Process.ArgvAsync;
        var argvLength = argv != null ? argv.Length.ToString() : "null";
        Console.WriteLine($"Electron.Procsss.ArgvAsync.Length='{argvLength}'");
        if (argv != null)
        {
            var msg = "\n";
            for (var i = 0; i < argv.Length; i++)
            {
                msg += $"argv[{i}]='{argv[i]}'\n";
            }

            Console.WriteLine(msg);
        }

        var versions = await Electron.Process.VersionsAsync;
        Console.WriteLine($"Electron.Procsss.VersionsAsync='[Chrome={versions.Chrome}, Electron={versions.Electron}']");

        Console.WriteLine($"Electron.Procsss.DefaultAppAsync='{await Electron.Process.DefaultAppAsync}'");
        Console.WriteLine($"Electron.Procsss.IsMainFrameAsync='{await Electron.Process.IsMainFrameAsync}'");
        Console.WriteLine($"Electron.Procsss.ResourcesPathAsync='{await Electron.Process.ResourcesPathAsync}'");
        Console.WriteLine($"Electron.Procsss.UpTimeAsync='{await Electron.Process.UpTimeAsync}'");
        Console.WriteLine($"Electron.Procsss.PidAsync='{await Electron.Process.PidAsync}'");
        Console.WriteLine($"Electron.Procsss.ArchAsync='{await Electron.Process.ArchAsync}'");
        Console.WriteLine($"Electron.Procsss.PlatformAsync='{await Electron.Process.PlatformAsync}'");
        Console.WriteLine($"VerifyProcessApi END------------");
    }

The generated the following results with no issues.

Results:

image


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ElectronNET/Electron.NET/pull/648 **Author:** [@schaveyt](https://github.com/schaveyt) **Created:** 12/29/2021 **Status:** ✅ Merged **Merged:** 4/6/2022 **Merged by:** [@GregorBiswanger](https://github.com/GregorBiswanger) **Base:** `master` ← **Head:** `feature/647-launching-app-w-file-win-linux` --- ### 📝 Commits (7) - [`8e1e184`](https://github.com/ElectronNET/Electron.NET/commit/8e1e184d1e1ef4682547d2dae8c6e7820eb22d38) #647 process argv for open-file for win and linux - [`1406fc1`](https://github.com/ElectronNET/Electron.NET/commit/1406fc1d798ada0d98e30bf712ce4da491d98f64) #647 add initial Process class to ElectronNET.API - [`562cccb`](https://github.com/ElectronNET/Electron.NET/commit/562cccbfae8a9230aa19490976fb3b39bf79c294) #647 add to ElectronNET.API Process member interfaces for argv and type - [`ba82b9a`](https://github.com/ElectronNET/Electron.NET/commit/ba82b9a600ab9264584b6747af9484868c5bdb79) #647 add to ElectronNET.API Process member interfaces for various fields - [`5921481`](https://github.com/ElectronNET/Electron.NET/commit/592148116bcfc8aa5da2799fa74907f86ccb0d59) #647 correct to ElectronNET.API Process member for versions field - [`24a2005`](https://github.com/ElectronNET/Electron.NET/commit/24a20057761b7ec8e71ccdac8d8e316f428b86e4) #647 update XML documentation to ElectronNET.API Process members - [`64e058b`](https://github.com/ElectronNET/Electron.NET/commit/64e058b0b59a4fbbd6c0ec9de2ee1850a66684c4) #647 make ProcessVersions Entity a record to ensure readonly access to props ### 📊 Changes **11 files changed** (+452 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `ElectronNET.API/BridgeConnector.cs` (+109 -1) 📝 `ElectronNET.API/Electron.cs` (+5 -0) ➕ `ElectronNET.API/Entities/ProcessVersions.cs` (+10 -0) ➕ `ElectronNET.API/Process.cs` (+185 -0) 📝 `ElectronNET.API/ServiceCollectionExtensions.cs` (+2 -1) 📝 `ElectronNET.CLI/Commands/Actions/DeployEmbeddedElectronFiles.cs` (+1 -0) 📝 `ElectronNET.CLI/ElectronNET.CLI.csproj` (+1 -0) ➕ `ElectronNET.Host/api/process.js` (+62 -0) ➕ `ElectronNET.Host/api/process.js.map` (+1 -0) ➕ `ElectronNET.Host/api/process.ts` (+73 -0) 📝 `ElectronNET.Host/main.js` (+3 -0) </details> ### 📄 Description ## Status: Review Approved ### Summary Addresses #647 and remains compatible with existing behavior of passing arguments via /args commandline option. This has been built and integration tested locally by invoking via electronize start as well as the compiled executable as described in the issue #647. ### Change Summary 1. Added the new Process class and singleton, this required: 1. Updating ElectronNET.API/Electron.cs to add access to the Process singleton 1. Updating ElectronNET.API/ServiceCollectionExtensions.cs to register Process singleton to the DI container 1. Updating ElectronNET.CLI/Commands/Actions/DeployEmbeddedElectronFiles.cs to deploy the new embed the new .js file 1. Updating ElectronNET.CLI/ElectronNET.CLI.csproj to embed the new process.js file to the CLI. 1. Creating ElectronNET.Host/api/process.ts to interact with Electron's process object from the node side 1. Creating ElectronNET.API/Process.cs to bridge with the electron api 1. Updating ElectronNET.Host/main.js to initialize the processApi object. 1. Updated ElectronNET.API/BridgeConnector.cs to add reusable methods to obtaining values over the Socket interface. 1. Updated ElectronNET.API/Entities/ProcessVersion.cs as corresponding type to the electron.process.versions type. ### Verification Summary I was not able to get the WebApp project running however I was able to get my target project running with the update API & CLI changes. I created a simple test method as follows: ~~~csharp public async void VerifyProcessApi() { Console.WriteLine($"VerifyProcessApi START------------"); Console.WriteLine($"Electron.Procsss.ExecPath='{await Electron.Process.ExecPathAsync}'"); Console.WriteLine($"Electron.Procsss.TypeAsync='{await Electron.Process.TypeAsync}'"); var argv = await Electron.Process.ArgvAsync; var argvLength = argv != null ? argv.Length.ToString() : "null"; Console.WriteLine($"Electron.Procsss.ArgvAsync.Length='{argvLength}'"); if (argv != null) { var msg = "\n"; for (var i = 0; i < argv.Length; i++) { msg += $"argv[{i}]='{argv[i]}'\n"; } Console.WriteLine(msg); } var versions = await Electron.Process.VersionsAsync; Console.WriteLine($"Electron.Procsss.VersionsAsync='[Chrome={versions.Chrome}, Electron={versions.Electron}']"); Console.WriteLine($"Electron.Procsss.DefaultAppAsync='{await Electron.Process.DefaultAppAsync}'"); Console.WriteLine($"Electron.Procsss.IsMainFrameAsync='{await Electron.Process.IsMainFrameAsync}'"); Console.WriteLine($"Electron.Procsss.ResourcesPathAsync='{await Electron.Process.ResourcesPathAsync}'"); Console.WriteLine($"Electron.Procsss.UpTimeAsync='{await Electron.Process.UpTimeAsync}'"); Console.WriteLine($"Electron.Procsss.PidAsync='{await Electron.Process.PidAsync}'"); Console.WriteLine($"Electron.Procsss.ArchAsync='{await Electron.Process.ArchAsync}'"); Console.WriteLine($"Electron.Procsss.PlatformAsync='{await Electron.Process.PlatformAsync}'"); Console.WriteLine($"VerifyProcessApi END------------"); } ~~~ The generated the following results with no issues. __Results:__ ![image](https://user-images.githubusercontent.com/10182644/147899830-a3894d49-dcc8-4976-b847-1bdd7e9d3172.png) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 16:58:50 +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#1241