Skip to content

Commit 683d58c

Browse files
committed
fix(nsis): StartApp doesn't work if menuCategory used
Close #1151, Close #1412
1 parent 5a2631c commit 683d58c

File tree

6 files changed

+19
-16
lines changed

6 files changed

+19
-16
lines changed

packages/electron-builder/src/targets/nsis.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ export default class NsisTarget extends Target {
282282
defines.allowToChangeInstallationDirectory = null
283283
}
284284

285-
if (options.menuCategory != null) {
285+
if (options.menuCategory != null && options.menuCategory !== false) {
286286
const menu = sanitizeFileName(options.menuCategory === true ? packager.appInfo.companyName : <string>options.menuCategory)
287287
if (!isEmptyOrSpaces(menu)) {
288288
defines.MENU_FILENAME = menu

packages/electron-builder/templates/nsis/boringInstaller.nsh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
!ifndef BUILD_UNINSTALLER
99
Function StartApp
1010
${if} ${Updated}
11-
${StdUtils.ExecShellAsUser} $0 "$SMPROGRAMS\${PRODUCT_FILENAME}.lnk" "open" "--updated"
11+
${StdUtils.ExecShellAsUser} $0 "$startMenuLink" "open" "--updated"
1212
${else}
13-
${StdUtils.ExecShellAsUser} $0 "$SMPROGRAMS\${PRODUCT_FILENAME}.lnk" "open" ""
13+
${StdUtils.ExecShellAsUser} $0 "$startMenuLink" "open" ""
1414
${endif}
1515
FunctionEnd
1616

packages/electron-builder/templates/nsis/installSection.nsh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ WinShell::SetLnkAUMI "$desktopLink" "${APP_ID}"
184184
${IfNot} ${Silent}
185185
# otherwise app window will be in backround
186186
HideWindow
187-
Call StartApp
187+
!insertmacro StartApp
188188
${EndIf}
189189
!endif
190190
!insertmacro quitSuccess

packages/electron-builder/templates/nsis/installer.nsi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
Var startMenuLink
2+
Var desktopLink
3+
14
!include "common.nsh"
25
!include "MUI2.nsh"
36
!include "multiUser.nsh"
@@ -23,9 +26,6 @@
2326
!insertmacro customHeader
2427
!endif
2528

26-
Var startMenuLink
27-
Var desktopLink
28-
2929
!ifdef BUILD_UNINSTALLER
3030
SilentInstall silent
3131
!else

packages/electron-builder/templates/nsis/oneClick.nsh

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
!ifndef BUILD_UNINSTALLER
22
!ifdef RUN_AFTER_FINISH
33
!include StdUtils.nsh
4-
Function StartApp
4+
!macro StartApp
5+
Var /GLOBAL startAppArgs
6+
${if} ${Updated}
7+
StrCpy $startAppArgs "--updated"
8+
${else}
9+
StrCpy $startAppArgs ""
10+
${endif}
11+
512
!ifdef INSTALL_MODE_PER_ALL_USERS
6-
${StdUtils.ExecShellAsUser} $0 "$SMPROGRAMS\${PRODUCT_FILENAME}.lnk" "open" ""
13+
${StdUtils.ExecShellAsUser} $0 $startMenuLink "open" "$startAppArgs"
714
!else
8-
${if} ${Updated}
9-
ExecShell "" "$SMPROGRAMS\${PRODUCT_FILENAME}.lnk" "--updated"
10-
${else}
11-
ExecShell "" "$SMPROGRAMS\${PRODUCT_FILENAME}.lnk"
12-
${endif}
15+
ExecShell "" "$startMenuLink" "$startAppArgs"
1316
!endif
14-
FunctionEnd
17+
!macroend
1518
!endif
1619

1720
!ifmacrodef licensePage

test/src/windows/oneClickInstallerTest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ test.ifAll("menuCategory", app({
119119
},
120120
config: {
121121
nsis: {
122-
perMachine: true,
122+
oneClick: false,
123123
menuCategory: true,
124124
artifactName: "${productName} CustomName ${version}.${ext}"
125125
},

0 commit comments

Comments
 (0)