Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ElectronNET.API/Runtime/Data/BuildInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class BuildInfo

public string RuntimeIdentifier { get; internal set; }

public string ElectronSingleInstance { get; internal set; }
public bool ElectronSingleInstance { get; internal set; }

public string Title { get; internal set; }

Expand Down
8 changes: 2 additions & 6 deletions src/ElectronNET.API/Runtime/StartupManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,9 @@ private BuildInfo GatherBuildInfo()
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;
}
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When ElectronSingleInstance is not set or is an empty string, the bool.TryParse will fail and ElectronSingleInstance will remain as its default value (false). However, the default in ElectronNET.LateImport.targets is "true" (line 110). This creates an inconsistency where an unset property would result in false in C# but true in the package.json. Consider adding an else clause to set a default value of true to match the MSBuild default, or ensure the property is always explicitly set.

Suggested change
}
}
else if (string.IsNullOrEmpty(isSingleInstance))
{
// Match MSBuild default in ElectronNET.LateImport.targets when the property is unset
buildInfo.ElectronSingleInstance = true;
}

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

@softworkz softworkz Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is not correct. The default is only in the props file, but what matters is the value at the targets level (after everything that is defined in the .csproj file has been applied).
The value at the targets level is what goes into the metadata attribute and that's the same value that is used during compilation.
So this suggestion is totally wrong.


if (httpPort?.Length > 0 && int.TryParse(httpPort, out var port))
Expand Down
2 changes: 1 addition & 1 deletion src/ElectronNET.Host/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion src/ElectronNET/build/ElectronNET.LateImport.targets
Original file line number Diff line number Diff line change
Expand Up @@ -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)" />
Expand Down
2 changes: 1 addition & 1 deletion src/ElectronNET/build/package.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
},
"license": "$(License)",
"executable": "$(TargetName)",
"singleInstance": "$(ElectronSingleInstance)",
"singleInstance": $(ElectronSingleInstance),
"homepage": "$(ProjectUrl)",
"splashscreen": {
"imageFile": "$(ElectronSplashScreen)"
Expand Down