fix(bundler/nsis): use uninstallstring to find wix installation (#7326)

* 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>
This commit is contained in:
luofei 2023-07-08 09:26:40 +08:00 committed by GitHub
parent 0ae53f4139
commit 32218a6f8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 5 deletions

View File

@ -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.

View File

@ -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}}"
@ -31,8 +37,6 @@
Name "${PRODUCTNAME}"
BrandingText "{{copyright}}"
OutFile "${OUTFILE}"
Unicode true
SetCompressor /SOLID lzma
VIProductVersion "${VERSIONWITHBUILD}"
VIAddVersionKey "ProductName" "${PRODUCTNAME}"
@ -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:
@ -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"
@ -244,7 +252,7 @@ Function PageLeaveReinstall
HideWindow
ClearErrors
${If} $R5 == "wix"
${If} $R7 == "wix"
ReadRegStr $R1 HKLM "$R6" "UninstallString"
ExecWait '$R1' $0
${Else}