diff --git a/.changes/fix-nsis-previous-installation-method.md b/.changes/fix-nsis-previous-installation-method.md new file mode 100644 index 000000000000..452d4f5e85f8 --- /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 93f0159e3c93..a7136f5865ad 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}