Skip to content

Commit 44a010e

Browse files
authored
Merge pull request #996 from softworkz/submit_singleinstance
Fix ElectronSingleInstance handling
2 parents 1c99ab0 + 30037fc commit 44a010e

File tree

5 files changed

+6
-10
lines changed

5 files changed

+6
-10
lines changed

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/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.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/build/ElectronNET.LateImport.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
<TemplateProperty Include="ElectronSplashScreen" Value="$(ElectronSplashScreenFileName)" />
136136
<TemplateProperty Include="ElectronVersion" Value="$(ElectronVersion)" />
137137
<TemplateProperty Include="TargetName" Value="$(ElectronTargetName)" />
138-
<TemplateProperty Include="ElectronSingleInstance" Value="$(ElectronSingleInstance)" />
138+
<TemplateProperty Include="ElectronSingleInstance" Value="$(ElectronSingleInstance.ToLower())" />
139139
</ItemGroup>
140140

141141
<MakeDir Directories="$(ElectronIntermediateOutputPath)" />

src/ElectronNET/build/package.template.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
},
2424
"license": "$(License)",
2525
"executable": "$(TargetName)",
26-
"singleInstance": "$(ElectronSingleInstance)",
26+
"singleInstance": $(ElectronSingleInstance),
2727
"homepage": "$(ProjectUrl)",
2828
"splashscreen": {
2929
"imageFile": "$(ElectronSplashScreen)"

0 commit comments

Comments
 (0)