Skip to content

Commit 672ff6c

Browse files
committed
Implemented #1003
1 parent 7cd552a commit 672ff6c

6 files changed

Lines changed: 55 additions & 5 deletions

File tree

‎Changelog.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- Fixed resolution of unrelated target (#1099) @epsnm
1212
- Added target framework customization (#1095) @epsnm
1313
- Added configurable Electron root directory for custom packaging layouts (#1106) @DYH1319
14+
- Added `ElectronExecutableName` to separate the product name from the executable name (#1003) @AeonSake
1415
- Added build extensibility properties `ElectronSkipExecCommands` and `ElectronIntermediatePublishDir` (#1106) @DYH1319
1516

1617
# 0.5.2

‎docs/Using/Configuration.md‎

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,35 @@ These are the current default values when you don't make any changes:
2828
<ElectronPackageId>$(MSBuildProjectName.Replace(".", "-").ToLower())</ElectronPackageId>
2929
<ElectronBuilderJson>electron-builder.json</ElectronBuilderJson>
3030
<Title>$(MSBuildProjectName)</Title>
31+
<ElectronExecutableName></ElectronExecutableName>
3132
<ElectronRootDir>../..</ElectronRootDir>
3233
<ElectronSkipExecCommands>false</ElectronSkipExecCommands>
3334
</PropertyGroup>
3435
```
3536

37+
### Product Name and Executable Name
38+
39+
`Title` is the product name of the application. It is used for the window title, the installer, the macOS app bundle and the Linux desktop entry, and it may contain spaces and other characters that are awkward in a file name.
40+
41+
`ElectronExecutableName` controls the name of the executable inside the package (electron-builder's `executableName`). When it is not set, it defaults to the following behavior:
42+
43+
| Target | Default |
44+
| --- | --- |
45+
| Windows | `$(Title)` |
46+
| Linux / macOS | `$(ElectronPackageId)` |
47+
48+
So to ship a product called `My Great App` with a `mygreatapp` binary on every platform:
49+
50+
```xml
51+
<PropertyGroup>
52+
<Title>My Great App</Title>
53+
<ElectronExecutableName>mygreatapp</ElectronExecutableName>
54+
</PropertyGroup>
55+
```
56+
57+
> [!NOTE]
58+
> `ElectronExecutable` is a separate, advanced setting: it is the binary Electron.NET launches when the .NET app starts first. It defaults to `ElectronExecutableName` and only needs to be changed when the package contains a launcher stub (for example added by an electron-builder hook) that should be started instead of the Electron binary.
59+
3660
### Custom Packaging Layout
3761

3862
`ElectronRootDir` tells the .NET app where to find the Electron binary when it is started first (DotNet-First startup of a packaged app). The path is resolved relative to the directory of the .NET executable; absolute paths are used as-is.
@@ -86,11 +110,17 @@ Since electron builder still expects a `package.json` file to exist, ElectronNET
86110
"productName": "$(ElectronTitle)",
87111
"build": {
88112
"appId": "$(ElectronPackageId)",
113+
"win": {
114+
"executableName": "$(ElectronExecutableName)"
115+
},
116+
"mac": {
117+
"executableName": "$(ElectronExecutableName)"
118+
},
89119
"linux": {
90120
"desktop": {
91121
"entry": { "Name": "$(Title)" }
92122
},
93-
"executableName": "$(ElectronPackageId)"
123+
"executableName": "$(ElectronExecutableName)"
94124
},
95125
"deb": {
96126
"desktop": {

‎src/ElectronNET/build/ElectronNET.Core.targets‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33

4-
<PropertyGroup Condition="'$(ElectronExecutable)' == ''">
4+
<PropertyGroup Condition="'$(ElectronExecutableName)' == ''">
55
<WinPrefix>win</WinPrefix>
6-
<ElectronExecutable Condition="'$(RuntimeIdentifier.StartsWith($(WinPrefix)))' == 'true'">$(Title)</ElectronExecutable>
7-
<ElectronExecutable Condition="'$(RuntimeIdentifier.StartsWith($(WinPrefix)))' != 'true'">$(ElectronPackageId)</ElectronExecutable>
6+
<ElectronExecutableName Condition="'$(RuntimeIdentifier.StartsWith($(WinPrefix)))' == 'true'">$(Title)</ElectronExecutableName>
7+
<ElectronExecutableName Condition="'$(RuntimeIdentifier.StartsWith($(WinPrefix)))' != 'true'">$(ElectronPackageId)</ElectronExecutableName>
8+
</PropertyGroup>
9+
10+
<PropertyGroup>
11+
<!-- The binary Electron.NET launches. It only differs from the packaged executable in advanced
12+
scenarios, e.g. when a build hook adds a launcher stub to the package. -->
13+
<ElectronExecutable Condition="'$(ElectronExecutable)' == ''">$(ElectronExecutableName)</ElectronExecutable>
814
</PropertyGroup>
915

1016
<PropertyGroup>

‎src/ElectronNET/build/ElectronNET.LateImport.targets‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,7 @@ For more information, see: https://github.com/ElectronNET/Electron.NET/wiki/Migr
633633
app\package.json instead. -->
634634
<ItemGroup>
635635
<DevTemplateProperty Include="ElectronPackageId" Value="$(ElectronPackageId)" />
636+
<DevTemplateProperty Include="ElectronExecutableName" Value="$(ElectronExecutableName)" />
636637
<DevTemplateProperty Include="Title" Value="$(Title)" />
637638
<DevTemplateProperty Include="Version" Value="$(Version)" />
638639
</ItemGroup>

‎src/ElectronNET/build/ElectronNETRules.Project.xaml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,12 @@
553553
Category="General">
554554
</StringProperty>
555555

556+
<StringProperty Name="ElectronExecutableName"
557+
DisplayName="Executable Name"
558+
Description="Name of the executable inside the package, without extension. Defaults to the title on Windows and to the package id on Linux and macOS"
559+
Category="General">
560+
</StringProperty>
561+
556562
<StringProperty Name="ElectronRootDir"
557563
DisplayName="Electron Root Directory"
558564
Description="Location of the Electron binary relative to the .NET application directory of a packaged app. Default: ../.. (the .NET app lives in resources/bin)"

‎src/ElectronNET/build/package.dev.template.json‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@
44
"private": true,
55
"build": {
66
"appId": "$(ElectronPackageId)",
7+
"win": {
8+
"executableName": "$(ElectronExecutableName)"
9+
},
10+
"mac": {
11+
"executableName": "$(ElectronExecutableName)"
12+
},
713
"linux": {
814
"desktop": {
915
"entry": { "Name": "$(Title)" }
1016
},
11-
"executableName": "$(ElectronPackageId)"
17+
"executableName": "$(ElectronExecutableName)"
1218
},
1319
"deb": {
1420
"desktop": {

0 commit comments

Comments
 (0)