Skip to content

Commit 7e6760a

Browse files
authored
Merge pull request #998 from ElectronNET/develop
Release 0.4.0
2 parents cb20fba + 29fdbb5 commit 7e6760a

File tree

13 files changed

+195
-46
lines changed

13 files changed

+195
-46
lines changed

.github/workflows/retry-test-jobs.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,18 @@ jobs:
3232
echo "Jobs and conclusions:"
3333
echo "$jobs_json" | jq '.jobs[] | {name: .name, conclusion: .conclusion}'
3434
35-
failed_matrix_jobs=$(echo "$jobs_json" | jq '
35+
failed_matrix_jobs=$(echo "$jobs_json" | jq -r '
3636
[ .jobs[]
3737
| select(.conclusion == "failure"
3838
and (.name | contains(" API-")))
3939
]
40-
| length
40+
| length // 0
4141
')
42+
failed_matrix_jobs=${failed_matrix_jobs:-0}
4243
43-
echo "Failed Integration Tests matrix jobs: $failed_matrix_jobs"
44-
45-
if [ "$failed_matrix_jobs" -gt 0 ]; then
44+
if [ "${failed_matrix_jobs}" -gt 0 ]; then
4645
echo "Detected failing Integration Tests jobs – re-running failed jobs for this run."
47-
gh run rerun -R $REPO "$RUN_ID" --failed
46+
gh run rerun -R "$REPO" "$RUN_ID" --failed
4847
else
4948
echo "Only non-matrix jobs (like Test Results) failed – not auto-rerunning."
5049
fi

Changelog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# 0.4.0
2+
3+
## ElectronNET.Core
4+
5+
- Fixed ElectronSingleInstance handling (#996) @softworkz
6+
- Fixed `PackageId` handling (#993) @softworkz
7+
- Added cross-platform npm restore and check mismatch on publish (#988) @softworkz
8+
19
# 0.3.1
210

311
## ElectronNET.Core

docs/GettingStarted/Console-App.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Add the Electron.NET configuration to your `.csproj` file:
5454
</PropertyGroup>
5555

5656
<ItemGroup>
57-
<PackageReference Include="ElectronNET.Core" Version="0.3.1" />
57+
<PackageReference Include="ElectronNET.Core" Version="0.4.0" />
5858
</ItemGroup>
5959
```
6060

src/ElectronNET.API/Runtime/Data/BuildInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class BuildInfo
88

99
public string RuntimeIdentifier { get; internal set; }
1010

11-
public string ElectronSingleInstance { get; internal set; }
11+
public bool ElectronSingleInstance { get; internal set; }
1212

1313
public string Title { get; internal set; }
1414

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

Lines changed: 89 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
namespace ElectronNET.Runtime.Services.ElectronProcess
22
{
3-
using ElectronNET.Common;
4-
using ElectronNET.Runtime.Data;
53
using System;
64
using System.ComponentModel;
75
using System.IO;
6+
using System.Linq;
87
using System.Runtime.InteropServices;
98
using System.Threading.Tasks;
9+
using ElectronNET.Common;
10+
using ElectronNET.Runtime.Data;
1011

1112
/// <summary>
1213
/// Launches and manages the Electron app process.
@@ -33,14 +34,42 @@ public ElectronProcessActive(bool isUnpackaged, string electronBinaryName, strin
3334
this.socketPort = socketPort;
3435
}
3536

36-
protected override Task StartCore()
37+
protected override async Task StartCore()
3738
{
3839
var dir = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory);
3940
string startCmd, args, workingDir;
4041

4142
if (this.isUnpackaged)
4243
{
44+
this.CheckRuntimeIdentifier();
45+
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,17 +82,71 @@ 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;
6089
}
6190

62-
6391
// We don't await this in order to let the state transition to "Starting"
6492
Task.Run(async () => await this.StartInternal(startCmd, args, workingDir).ConfigureAwait(false));
93+
}
6594

66-
return Task.CompletedTask;
95+
private void CheckRuntimeIdentifier()
96+
{
97+
var buildInfoRid = ElectronNetRuntime.BuildInfo.RuntimeIdentifier;
98+
if (string.IsNullOrEmpty(buildInfoRid))
99+
{
100+
return;
101+
}
102+
103+
var osPart = buildInfoRid.Split('-').First();
104+
105+
var mismatch = false;
106+
107+
switch (osPart)
108+
{
109+
case "win":
110+
111+
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
112+
{
113+
mismatch = true;
114+
}
115+
116+
break;
117+
118+
case "linux":
119+
120+
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
121+
{
122+
mismatch = true;
123+
}
124+
125+
break;
126+
127+
case "osx":
128+
129+
if (!RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
130+
{
131+
mismatch = true;
132+
}
133+
134+
break;
135+
136+
case "freebsd":
137+
138+
if (!RuntimeInformation.IsOSPlatform(OSPlatform.FreeBSD))
139+
{
140+
mismatch = true;
141+
}
142+
143+
break;
144+
}
145+
146+
if (mismatch)
147+
{
148+
throw new PlatformNotSupportedException($"This Electron.NET application was built for '{buildInfoRid}'. It cannot run on this platform.");
149+
}
67150
}
68151

69152
protected override Task StopCore()

src/ElectronNET.API/Runtime/StartupManager.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,9 @@ private BuildInfo GatherBuildInfo()
165165
ElectronNetRuntime.DotnetAppType = DotnetAppType.AspNetCoreApp;
166166
}
167167

168-
if (isSingleInstance?.Length > 0 && bool.TryParse(isSingleInstance, out var isSingleInstanceActive) && isSingleInstanceActive)
168+
if (bool.TryParse(isSingleInstance, out var parsedBool))
169169
{
170-
buildInfo.ElectronSingleInstance = "yes";
171-
}
172-
else
173-
{
174-
buildInfo.ElectronSingleInstance = "no";
170+
buildInfo.ElectronSingleInstance = parsedBool;
175171
}
176172

177173
if (httpPort?.Length > 0 && int.TryParse(httpPort, out var port))

src/ElectronNET.ConsoleApp/ElectronNET.ConsoleApp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
<ProjectReference Include="..\ElectronNET.API\ElectronNET.API.csproj" Condition="$(ElectronNetDevMode)" />
7171
</ItemGroup>
7272
<ItemGroup>
73-
<PackageReference Include="ElectronNET.Core" Version="0.3.1" Condition="'$(ElectronNetDevMode)' != 'true'" />
73+
<PackageReference Include="ElectronNET.Core" Version="0.4.0" Condition="'$(ElectronNetDevMode)' != 'true'" />
7474
</ItemGroup>
7575

7676
<Import Project="..\ElectronNET\build\ElectronNET.Core.targets" Condition="$(ElectronNetDevMode)" />

src/ElectronNET.Host/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ app.on('will-finish-launching', () => {
9393

9494
const manifestJsonFile = require(manifestJsonFilePath);
9595

96-
if (manifestJsonFile.singleInstance === "yes") {
96+
if (manifestJsonFile.singleInstance) {
9797
const mainInstance = app.requestSingleInstanceLock();
9898
app.on('second-instance', (events, args = []) => {
9999
args.forEach((parameter) => {

src/ElectronNET.WebApp/ElectronNET.WebApp.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@
7676
<ProjectReference Include="..\ElectronNET.AspNet\ElectronNET.AspNet.csproj" Condition="$(ElectronNetDevMode)" />
7777
</ItemGroup>
7878
<ItemGroup>
79-
<PackageReference Include="ElectronNET.Core" Version="0.3.1" Condition="'$(ElectronNetDevMode)' != 'true'" />
80-
<PackageReference Include="ElectronNET.Core.AspNet" Version="0.3.1" Condition="'$(ElectronNetDevMode)' != 'true'" />
79+
<PackageReference Include="ElectronNET.Core" Version="0.4.0" Condition="'$(ElectronNetDevMode)' != 'true'" />
80+
<PackageReference Include="ElectronNET.Core.AspNet" Version="0.4.0" Condition="'$(ElectronNetDevMode)' != 'true'" />
8181
<PackageReference Include="Microsoft.TypeScript.MSBuild" Version="5.9.3" />
8282
</ItemGroup>
8383

src/ElectronNET/build/ElectronNET.Core.targets

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
<_IsMsAspNetProject Condition="'$(UsingMicrosoftNETSdkWeb)' == 'true'">True</_IsMsAspNetProject>
1313
</PropertyGroup>
1414

15+
<PropertyGroup>
16+
<PackageId Condition="'$(PackageId)' == ''">$(ElectronPackageId)</PackageId>
17+
</PropertyGroup>
18+
1519
<ItemGroup>
1620
<AssemblyMetadata Include="ElectronExecutable" Value="$(ElectronExecutable)" />
1721
<AssemblyMetadata Include="ElectronVersion" Value="$(ElectronVersion)" />

0 commit comments

Comments
 (0)