Skip to content

Commit 8660093

Browse files
committed
fix: keep shortcuts only if old uninstaller app support it
Close #1704
1 parent d96cacc commit 8660093

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,4 @@ and other distributable formats.
176176
Public [archive](http://electron-builder.slackarchive.io) without registration.
177177

178178
## Further Reading
179-
See the [Wiki](https://github.com/electron-userland/electron-builder/wiki) for more documentation.
180-
181-
179+
See the [Wiki](https://github.com/electron-userland/electron-builder/wiki) for more documentation.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export class PkgTarget extends Target {
3434
const keychainName = (await packager.codeSigningInfo).keychainName
3535

3636
const appOutDir = this.outDir
37+
// https://developer.apple.com/library/content/documentation/DeveloperTools/Reference/DistributionDefinitionRef/Chapters/Distribution_XML_Ref.html
3738
const distInfoFile = path.join(appOutDir, "distribution.xml")
3839

3940
const innerPackageFile = path.join(appOutDir, `${filterCFBundleIdentifier(appInfo.id)}.pkg`)

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

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
!macroend
4646

4747
!macro registryAddInstallInfo
48-
WriteRegStr SHCTX "${INSTALL_REGISTRY_KEY}" InstallLocation "$INSTDIR"
48+
WriteRegStr SHELL_CONTEXT "${INSTALL_REGISTRY_KEY}" InstallLocation "$INSTDIR"
49+
WriteRegStr SHELL_CONTEXT "${INSTALL_REGISTRY_KEY}" KeepShortcuts "true"
4950

5051
${if} $installMode == "all"
5152
StrCpy $0 "/allusers"
@@ -55,27 +56,27 @@
5556
StrCpy $1 " (only current user)"
5657
${endif}
5758

58-
WriteRegStr SHCTX "${UNINSTALL_REGISTRY_KEY}" DisplayName "${UNINSTALL_DISPLAY_NAME}$1"
59+
WriteRegStr SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" DisplayName "${UNINSTALL_DISPLAY_NAME}$1"
5960
# https://github.com/electron-userland/electron-builder/issues/750
6061
StrCpy $2 "$INSTDIR\${UNINSTALL_FILENAME}"
61-
WriteRegStr SHCTX "${UNINSTALL_REGISTRY_KEY}" UninstallString '"$2" $0'
62+
WriteRegStr SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" UninstallString '"$2" $0'
6263

63-
WriteRegStr SHCTX "${UNINSTALL_REGISTRY_KEY}" "DisplayVersion" "${VERSION}"
64+
WriteRegStr SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" "DisplayVersion" "${VERSION}"
6465
!ifdef UNINSTALLER_ICON
65-
WriteRegStr SHCTX "${UNINSTALL_REGISTRY_KEY}" "DisplayIcon" "$INSTDIR\uninstallerIcon.ico"
66+
WriteRegStr SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" "DisplayIcon" "$INSTDIR\uninstallerIcon.ico"
6667
!else
67-
WriteRegStr SHCTX "${UNINSTALL_REGISTRY_KEY}" "DisplayIcon" "$appExe,0"
68+
WriteRegStr SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" "DisplayIcon" "$appExe,0"
6869
!endif
6970

7071
!ifdef COMPANY_NAME
71-
WriteRegStr SHCTX "${UNINSTALL_REGISTRY_KEY}" "Publisher" "${COMPANY_NAME}"
72+
WriteRegStr SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" "Publisher" "${COMPANY_NAME}"
7273
!endif
73-
WriteRegDWORD SHCTX "${UNINSTALL_REGISTRY_KEY}" NoModify 1
74-
WriteRegDWORD SHCTX "${UNINSTALL_REGISTRY_KEY}" NoRepair 1
74+
WriteRegDWORD SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" NoModify 1
75+
WriteRegDWORD SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" NoRepair 1
7576

7677
${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
7778
IntFmt $0 "0x%08X" $0
78-
WriteRegDWORD SHCTX "${UNINSTALL_REGISTRY_KEY}" "EstimatedSize" "$0"
79+
WriteRegDWORD SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" "EstimatedSize" "$0"
7980
!macroend
8081

8182
InitPluginsDir
@@ -88,7 +89,10 @@ StrCpy $appExe "$INSTDIR\${APP_EXECUTABLE_FILENAME}"
8889
Var /GLOBAL shortcuts
8990
StrCpy $shortcuts ""
9091
!ifndef allowToChangeInstallationDirectory
91-
${if} ${FileExists} "$appExe"
92+
ReadRegStr $R1 SHELL_CONTEXT "${INSTALL_REGISTRY_KEY}" KeepShortcuts
93+
94+
${if} $R1 == "true"
95+
${andIf} ${FileExists} "$appExe"
9296
StrCpy $shortcuts "--keep-shortcuts"
9397
${endIf}
9498
!endif

0 commit comments

Comments
 (0)