Skip to content

Commit

Permalink
fix(bundler/nsis): use uninstallstring to find wix installation (#7326)
Browse files Browse the repository at this point in the history
* add change file

Signed-off-by: luofei <luoffei@outlook.com>

* fix(bundler/nsis): Check if the previous installation was done using WiX

Signed-off-by: luofei <luoffei@outlook.com>

* Update .changes/fix-nsis-previous-installation-method.md

---------

Signed-off-by: luofei <luoffei@outlook.com>
  • Loading branch information
luoffei authored Jul 8, 2023
1 parent 0ae53f4 commit 32218a6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changes/fix-nsis-previous-installation-method.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'tauri-bundler': 'patch:bug'
---

On Windows, fix NSIS installer identifying a previous NSIS-installed app as WiX-installed app and then fails to uninstall it.
18 changes: 13 additions & 5 deletions tooling/bundler/src/bundle/windows/templates/installer.nsi
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
Unicode true
SetCompressor /SOLID lzma

!include MUI2.nsh
!include FileFunc.nsh
!include x64.nsh
!include WordFunc.nsh
!include "StrFunc.nsh"
${StrCase}
${StrLoc}

!define MANUFACTURER "{{manufacturer}}"
!define PRODUCTNAME "{{product_name}}"
Expand Down Expand Up @@ -31,8 +37,6 @@
Name "${PRODUCTNAME}"
BrandingText "{{copyright}}"
OutFile "${OUTFILE}"
Unicode true
SetCompressor /SOLID lzma

VIProductVersion "${VERSIONWITHBUILD}"
VIAddVersionKey "ProductName" "${PRODUCTNAME}"
Expand Down Expand Up @@ -135,7 +139,11 @@ Function PageReinstall
ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$1" "DisplayName"
ReadRegStr $R1 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$1" "Publisher"
StrCmp "$R0$R1" "${PRODUCTNAME}${MANUFACTURER}" 0 wix_loop
StrCpy $R5 "wix"
ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$1" "UninstallString"
${StrCase} $R1 $R0 "L"
${StrLoc} $R0 $R1 "msiexec" ">"
StrCmp $R0 0 0 wix_done
StrCpy $R7 "wix"
StrCpy $R6 "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$1"
Goto compare_version
wix_done:
Expand All @@ -149,7 +157,7 @@ Function PageReinstall
; and modify the messages presented to the user accordingly
compare_version:
StrCpy $R4 "$(older)"
${If} $R5 == "wix"
${If} $R7 == "wix"
ReadRegStr $R0 HKLM "$R6" "DisplayVersion"
${Else}
ReadRegStr $R0 SHCTX "${UNINSTKEY}" "DisplayVersion"
Expand Down Expand Up @@ -244,7 +252,7 @@ Function PageLeaveReinstall
HideWindow
ClearErrors

${If} $R5 == "wix"
${If} $R7 == "wix"
ReadRegStr $R1 HKLM "$R6" "UninstallString"
ExecWait '$R1' $0
${Else}
Expand Down

0 comments on commit 32218a6

Please sign in to comment.