From 32218a6f8c1d90c2503e7cbc4523e4ab464ba032 Mon Sep 17 00:00:00 2001 From: luofei Date: Sat, 8 Jul 2023 09:26:40 +0800 Subject: [PATCH] fix(bundler/nsis): use uninstallstring to find wix installation (#7326) * add change file Signed-off-by: luofei * fix(bundler/nsis): Check if the previous installation was done using WiX Signed-off-by: luofei * Update .changes/fix-nsis-previous-installation-method.md --------- Signed-off-by: luofei --- .../fix-nsis-previous-installation-method.md | 5 +++++ .../src/bundle/windows/templates/installer.nsi | 18 +++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 .changes/fix-nsis-previous-installation-method.md diff --git a/.changes/fix-nsis-previous-installation-method.md b/.changes/fix-nsis-previous-installation-method.md new file mode 100644 index 000000000..452d4f5e8 --- /dev/null +++ b/.changes/fix-nsis-previous-installation-method.md @@ -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. diff --git a/tooling/bundler/src/bundle/windows/templates/installer.nsi b/tooling/bundler/src/bundle/windows/templates/installer.nsi index 93f0159e3..a7136f586 100644 --- a/tooling/bundler/src/bundle/windows/templates/installer.nsi +++ b/tooling/bundler/src/bundle/windows/templates/installer.nsi @@ -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}