From 8660093d41718f326d0e0f3dae6f6326fe7489d6 Mon Sep 17 00:00:00 2001 From: develar Date: Tue, 20 Jun 2017 20:04:26 +0200 Subject: [PATCH] fix: keep shortcuts only if old uninstaller app support it Close #1704 --- README.md | 4 +-- packages/electron-builder/src/targets/pkg.ts | 1 + .../templates/nsis/installSection.nsh | 26 +++++++++++-------- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index cdeaeaf1198..d8d35b34c72 100644 --- a/README.md +++ b/README.md @@ -176,6 +176,4 @@ and other distributable formats. Public [archive](http://electron-builder.slackarchive.io) without registration. ## Further Reading -See the [Wiki](https://github.com/electron-userland/electron-builder/wiki) for more documentation. - - +See the [Wiki](https://github.com/electron-userland/electron-builder/wiki) for more documentation. \ No newline at end of file diff --git a/packages/electron-builder/src/targets/pkg.ts b/packages/electron-builder/src/targets/pkg.ts index 06d1c2391f4..d8c06c4af50 100644 --- a/packages/electron-builder/src/targets/pkg.ts +++ b/packages/electron-builder/src/targets/pkg.ts @@ -34,6 +34,7 @@ export class PkgTarget extends Target { const keychainName = (await packager.codeSigningInfo).keychainName const appOutDir = this.outDir + // https://developer.apple.com/library/content/documentation/DeveloperTools/Reference/DistributionDefinitionRef/Chapters/Distribution_XML_Ref.html const distInfoFile = path.join(appOutDir, "distribution.xml") const innerPackageFile = path.join(appOutDir, `${filterCFBundleIdentifier(appInfo.id)}.pkg`) diff --git a/packages/electron-builder/templates/nsis/installSection.nsh b/packages/electron-builder/templates/nsis/installSection.nsh index 2d3ea5b73ce..9feb2fdd215 100644 --- a/packages/electron-builder/templates/nsis/installSection.nsh +++ b/packages/electron-builder/templates/nsis/installSection.nsh @@ -45,7 +45,8 @@ !macroend !macro registryAddInstallInfo - WriteRegStr SHCTX "${INSTALL_REGISTRY_KEY}" InstallLocation "$INSTDIR" + WriteRegStr SHELL_CONTEXT "${INSTALL_REGISTRY_KEY}" InstallLocation "$INSTDIR" + WriteRegStr SHELL_CONTEXT "${INSTALL_REGISTRY_KEY}" KeepShortcuts "true" ${if} $installMode == "all" StrCpy $0 "/allusers" @@ -55,27 +56,27 @@ StrCpy $1 " (only current user)" ${endif} - WriteRegStr SHCTX "${UNINSTALL_REGISTRY_KEY}" DisplayName "${UNINSTALL_DISPLAY_NAME}$1" + WriteRegStr SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" DisplayName "${UNINSTALL_DISPLAY_NAME}$1" # https://github.com/electron-userland/electron-builder/issues/750 StrCpy $2 "$INSTDIR\${UNINSTALL_FILENAME}" - WriteRegStr SHCTX "${UNINSTALL_REGISTRY_KEY}" UninstallString '"$2" $0' + WriteRegStr SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" UninstallString '"$2" $0' - WriteRegStr SHCTX "${UNINSTALL_REGISTRY_KEY}" "DisplayVersion" "${VERSION}" + WriteRegStr SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" "DisplayVersion" "${VERSION}" !ifdef UNINSTALLER_ICON - WriteRegStr SHCTX "${UNINSTALL_REGISTRY_KEY}" "DisplayIcon" "$INSTDIR\uninstallerIcon.ico" + WriteRegStr SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" "DisplayIcon" "$INSTDIR\uninstallerIcon.ico" !else - WriteRegStr SHCTX "${UNINSTALL_REGISTRY_KEY}" "DisplayIcon" "$appExe,0" + WriteRegStr SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" "DisplayIcon" "$appExe,0" !endif !ifdef COMPANY_NAME - WriteRegStr SHCTX "${UNINSTALL_REGISTRY_KEY}" "Publisher" "${COMPANY_NAME}" + WriteRegStr SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" "Publisher" "${COMPANY_NAME}" !endif - WriteRegDWORD SHCTX "${UNINSTALL_REGISTRY_KEY}" NoModify 1 - WriteRegDWORD SHCTX "${UNINSTALL_REGISTRY_KEY}" NoRepair 1 + WriteRegDWORD SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" NoModify 1 + WriteRegDWORD SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" NoRepair 1 ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2 IntFmt $0 "0x%08X" $0 - WriteRegDWORD SHCTX "${UNINSTALL_REGISTRY_KEY}" "EstimatedSize" "$0" + WriteRegDWORD SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" "EstimatedSize" "$0" !macroend InitPluginsDir @@ -88,7 +89,10 @@ StrCpy $appExe "$INSTDIR\${APP_EXECUTABLE_FILENAME}" Var /GLOBAL shortcuts StrCpy $shortcuts "" !ifndef allowToChangeInstallationDirectory - ${if} ${FileExists} "$appExe" + ReadRegStr $R1 SHELL_CONTEXT "${INSTALL_REGISTRY_KEY}" KeepShortcuts + + ${if} $R1 == "true" + ${andIf} ${FileExists} "$appExe" StrCpy $shortcuts "--keep-shortcuts" ${endIf} !endif