Skip to content

Commit

Permalink
fix: keep shortcuts only if old uninstaller app support it
Browse files Browse the repository at this point in the history
Close #1704
  • Loading branch information
develar committed Jun 20, 2017
1 parent d96cacc commit 8660093
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
1 change: 1 addition & 0 deletions packages/electron-builder/src/targets/pkg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand Down
26 changes: 15 additions & 11 deletions packages/electron-builder/templates/nsis/installSection.nsh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 8660093

Please sign in to comment.