Skip to content

Commit c542e34

Browse files
committed
fix: wix template
1 parent 86df353 commit c542e34

File tree

2 files changed

+126
-0
lines changed

2 files changed

+126
-0
lines changed

forge.config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { MakerZIP } from '@electron-forge/maker-zip'
88
import { FusesPlugin } from '@electron-forge/plugin-fuses'
99
import { VitePlugin } from '@electron-forge/plugin-vite'
1010
import type { ForgeConfig, ForgeMakeResult } from '@electron-forge/shared-types'
11+
import fs from 'fs'
1112
import path from 'path'
1213

1314
import { CUSTOM_APP_PROTOCOL } from './src/main/deepLinks.constants'
@@ -104,6 +105,15 @@ const config: ForgeConfig = {
104105
ui: {
105106
chooseDirectory: true,
106107
},
108+
// Use custom WiX template that points shortcuts directly to the real exe
109+
// in the versioned subfolder, bypassing the broken stub launcher
110+
// (see https://github.com/electron-userland/electron-wix-msi/issues/161)
111+
beforeCreate: async (creator) => {
112+
creator.wixTemplate = fs.readFileSync(
113+
path.join(__dirname, 'resources', 'wix-template.xml'),
114+
'utf-8'
115+
)
116+
},
107117
}),
108118
new MakerZIP({}, ['darwin']),
109119
new MakerDMG(

resources/wix-template.xml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
2+
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
3+
<Product Id="{{ProductCode}}"
4+
UpgradeCode="{{UpgradeCode}}"
5+
Name = "{{ApplicationName}} (Machine - MSI)"
6+
Version="{{Version}}"
7+
Manufacturer="{{Manufacturer}}"
8+
Language="{{Language}}">
9+
<Package InstallerVersion="405"
10+
Compressed="yes"
11+
Comments="Windows Installer Package"
12+
Platform="{{Platform}}"
13+
InstallScope="{{PackageScope}}"/>
14+
<MajorUpgrade AllowSameVersionUpgrades="yes" DowngradeErrorMessage="A later version of this product is already installed. Setup will now exit."/>
15+
<Property Id="ARPSYSTEMCOMPONENT" Value="1" />
16+
<Property Id="VisibleProductName" Value="{{ApplicationName}} (Machine)" />
17+
<Property Id="MSIINSTALLPERUSER" Secure="yes" Value="{{InstallPerUser}}" />
18+
<Property Id="REINSTALLMODE" Value="emus" />
19+
<Property Id="REBOOT" Value="{{RebootMode}}" />
20+
<Property Id="INSTALLLEVEL" Value="{{InstallLevel}}" />
21+
<Property Id="UPDATERUSERGROUP" Value="Users" />
22+
<Property Id="AUTOUPDATEENABLED" Value="1" />
23+
<Property Id="INSTALLPATH">
24+
<RegistrySearch Key="SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{{ProductCode}}}.msq"
25+
Root="HKCU"
26+
Type="raw"
27+
Id="INSTALLPATH_REGSEARCH_HKCU"
28+
Name="InstallPath"
29+
Win64="{{Win64YesNo}}"/>
30+
<RegistrySearch Key="SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{{ProductCode}}}.msq"
31+
Root="HKLM"
32+
Type="raw"
33+
Id="INSTALLPATH_REGSEARCH_HKLM"
34+
Name="InstallPath"
35+
Win64="{{Win64YesNo}}"/>
36+
</Property>
37+
<SetProperty Action="SetVisibleProductName" Id="VisibleProductName" Sequence="both" Before="AppSearch" Value="{{ApplicationName}} (User)">
38+
<![CDATA[MSIINSTALLPERUSER = "1"]]>
39+
</SetProperty>
40+
<SetProperty Action="SetProductName" Id="ProductName" Sequence="both" Before="AppSearch" Value="{{ApplicationName}} (User - MSI)">
41+
<![CDATA[MSIINSTALLPERUSER = "1"]]>
42+
</SetProperty>
43+
44+
<Media Id="1" Cabinet="product.cab" EmbedCab="yes"/>
45+
<!-- {{Icon}}-->
46+
<!-- {{UI}} -->
47+
48+
<Directory Id="TARGETDIR" Name="SourceDir">
49+
<Directory Id="{{ProgramFilesFolder}}">
50+
<!-- {{Directories}} -->
51+
</Directory>
52+
53+
<Directory Id="DesktopFolder" Name="Desktop" />
54+
55+
<Directory Id="ProgramMenuFolder">
56+
<Directory Id="ApplicationProgramsFolder" Name="{{ShortcutFolderName}}"/>
57+
</Directory>
58+
</Directory>
59+
60+
<!-- Start Menu shortcut - targets the real exe in versioned subfolder, bypassing broken stub -->
61+
<DirectoryRef Id="ApplicationProgramsFolder">
62+
<Component Id="ApplicationShortcut" Guid="{{ApplicationShortcutGuid}}" Win64="{{Win64YesNo}}">
63+
<Shortcut Id="ApplicationStartMenuShortcut"
64+
Name="{{ShortcutName}}"
65+
Description="{{ApplicationDescription}}"
66+
Target="[APPLICATIONROOTDIRECTORY]app-{{SemanticVersion}}\{{ApplicationBinary}}.exe"
67+
WorkingDirectory="APPLICATIONROOTDIRECTORY">
68+
<!-- {{ShortcutProperties}} -->
69+
</Shortcut>
70+
<RemoveFolder Id="ApplicationProgramsFolder" On="uninstall"/>
71+
<RegistryValue Root="HKCU"
72+
Key="Software\Microsoft\{{ApplicationShortName}}"
73+
Name="installed"
74+
Type="integer"
75+
Value="1"
76+
KeyPath="yes"/>
77+
</Component>
78+
</DirectoryRef>
79+
80+
<!-- Desktop shortcut - targets the real exe in versioned subfolder, bypassing broken stub -->
81+
<DirectoryRef Id="DesktopFolder">
82+
<Component Id="DesktopShortcut" Guid="{{DesktopShortcutGuid}}" >
83+
<Shortcut Id="MyDesktopShortcut"
84+
Name="{{ShortcutName}}"
85+
Description="{{ApplicationDescription}}"
86+
Target="[APPLICATIONROOTDIRECTORY]app-{{SemanticVersion}}\{{ApplicationBinary}}.exe"
87+
WorkingDirectory="APPLICATIONROOTDIRECTORY"/>
88+
<RegistryValue Root="HKCU"
89+
Key="Software\Microsoft\{{ApplicationShortName}}"
90+
Name="installed"
91+
Type="integer"
92+
Value="1"
93+
KeyPath="yes" />
94+
</Component>
95+
</DirectoryRef>
96+
97+
<DirectoryRef Id="APPLICATIONROOTDIRECTORY">
98+
<Component Id="PurgeOnUninstall" Guid="{{RandomGuid}}" Win64="{{Win64YesNo}}">
99+
<CreateFolder/>
100+
<util:RemoveFolderEx On="uninstall" Property="INSTALLPATH" />
101+
</Component>
102+
</DirectoryRef>
103+
104+
<Feature Id="Complete" Title="{{ApplicationName}} ({{SemanticVersion}})" Description="The complete package." Display="expand" Level="1" {{ConfigurableDirectory}}>
105+
<Feature Id="MainApplication" Title="Main Application" Level="1" Description="The main components to run the applications." >
106+
<!-- {{ComponentRefs}} -->
107+
<ComponentRef Id="ApplicationShortcut" />
108+
<ComponentRef Id="DesktopShortcut" />
109+
<ComponentRef Id="PurgeOnUninstall" />
110+
</Feature>
111+
<!-- {{AutoLaunchFeature}} -->
112+
<!-- {{AutoUpdateFeature}} -->
113+
</Feature>
114+
<!-- {{AutoRun}} -->
115+
</Product>
116+
</Wix>

0 commit comments

Comments
 (0)