WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 1d6ef7a

Browse files
committed
ElectronProcessActive: Mark binaries as executable when debugging
1 parent 2d6d4e2 commit 1d6ef7a

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

src/ElectronNET.API/Runtime/Services/ElectronProcess/ElectronProcessActive.cs

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55
using System;
66
using System.ComponentModel;
77
using System.IO;
8+
using System.Linq;
89
using System.Runtime.InteropServices;
910
using System.Threading.Tasks;
11+
using ElectronNET.Common;
12+
using ElectronNET.Runtime.Data;
1013

1114
/// <summary>
1215
/// Launches and manages the Electron app process.
@@ -33,14 +36,40 @@ public ElectronProcessActive(bool isUnpackaged, string electronBinaryName, strin
3336
this.socketPort = socketPort;
3437
}
3538

36-
protected override Task StartCore()
39+
protected override async Task StartCore()
3740
{
3841
var dir = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory);
3942
string startCmd, args, workingDir;
4043

4144
if (this.isUnpackaged)
4245
{
4346
var electrondir = Path.Combine(dir.FullName, ".electron");
47+
48+
ProcessRunner chmodRunner = null;
49+
50+
try
51+
{
52+
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
53+
{
54+
var distFolder = Path.Combine(electrondir, "node_modules", "electron", "dist");
55+
56+
chmodRunner = new ProcessRunner("ElectronRunner-Chmod");
57+
chmodRunner.Run("chmod", "-R +x " + distFolder, electrondir);
58+
await chmodRunner.WaitForExitAsync().ConfigureAwait(true);
59+
60+
if (chmodRunner.LastExitCode != 0)
61+
{
62+
throw new Exception("Failed to set executable permissions on Electron dist folder.");
63+
}
64+
}
65+
}
66+
catch (Exception ex)
67+
{
68+
Console.Error.WriteLine("[StartCore]: Exception: " + chmodRunner?.StandardError);
69+
Console.Error.WriteLine("[StartCore]: Exception: " + chmodRunner?.StandardOutput);
70+
Console.Error.WriteLine("[StartCore]: Exception: " + ex);
71+
}
72+
4473
startCmd = Path.Combine(electrondir, "node_modules", "electron", "dist", "electron");
4574

4675
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
@@ -53,7 +82,7 @@ protected override Task StartCore()
5382
}
5483
else
5584
{
56-
dir = dir.Parent?.Parent;
85+
dir = dir.Parent!.Parent!;
5786
startCmd = Path.Combine(dir.FullName, this.electronBinaryName);
5887
args = $"-dotnetpacked -electronforcedport={this.socketPort:D} " + this.extraArguments;
5988
workingDir = dir.FullName;

0 commit comments

Comments
 (0)