Merge pull request #996 from softworkz/submit_singleinstance

Fix ElectronSingleInstance handling
This commit is contained in:
Florian Rappl
2025-12-18 21:56:59 +01:00
committed by GitHub
5 changed files with 6 additions and 10 deletions

View File

@@ -8,7 +8,7 @@
public string RuntimeIdentifier { get; internal set; }
public string ElectronSingleInstance { get; internal set; }
public bool ElectronSingleInstance { get; internal set; }
public string Title { get; internal set; }

View File

@@ -165,13 +165,9 @@
ElectronNetRuntime.DotnetAppType = DotnetAppType.AspNetCoreApp;
}
if (isSingleInstance?.Length > 0 && bool.TryParse(isSingleInstance, out var isSingleInstanceActive) && isSingleInstanceActive)
if (bool.TryParse(isSingleInstance, out var parsedBool))
{
buildInfo.ElectronSingleInstance = "yes";
}
else
{
buildInfo.ElectronSingleInstance = "no";
buildInfo.ElectronSingleInstance = parsedBool;
}
if (httpPort?.Length > 0 && int.TryParse(httpPort, out var port))

View File

@@ -93,7 +93,7 @@ app.on('will-finish-launching', () => {
const manifestJsonFile = require(manifestJsonFilePath);
if (manifestJsonFile.singleInstance === "yes") {
if (manifestJsonFile.singleInstance) {
const mainInstance = app.requestSingleInstanceLock();
app.on('second-instance', (events, args = []) => {
args.forEach((parameter) => {

View File

@@ -135,7 +135,7 @@
<TemplateProperty Include="ElectronSplashScreen" Value="$(ElectronSplashScreenFileName)" />
<TemplateProperty Include="ElectronVersion" Value="$(ElectronVersion)" />
<TemplateProperty Include="TargetName" Value="$(ElectronTargetName)" />
<TemplateProperty Include="ElectronSingleInstance" Value="$(ElectronSingleInstance)" />
<TemplateProperty Include="ElectronSingleInstance" Value="$(ElectronSingleInstance.ToLower())" />
</ItemGroup>
<MakeDir Directories="$(ElectronIntermediateOutputPath)" />

View File

@@ -23,7 +23,7 @@
},
"license": "$(License)",
"executable": "$(TargetName)",
"singleInstance": "$(ElectronSingleInstance)",
"singleInstance": $(ElectronSingleInstance),
"homepage": "$(ProjectUrl)",
"splashscreen": {
"imageFile": "$(ElectronSplashScreen)"