Skip to content

Commit b13cb20

Browse files
authored
fix(bundler): store and remove old main binary on updates if main binary name has change (#10962)
1 parent 00182eb commit b13cb20

3 files changed

Lines changed: 18 additions & 2 deletions

File tree

.changes/store-main-binary-name.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"tauri-bundler": "patch:feat"
3+
---
4+
5+
Store main binary name in registry for NSIS installer and delete old main binary on updates if the name changes.
6+

crates/tauri-bundler/src/bundle/windows/msi/wix.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,8 +546,9 @@ pub fn build_wix_app_installer(
546546
let shortcut_guid = generate_package_guid(settings).to_string();
547547
data.insert("shortcut_guid", to_json(shortcut_guid.as_str()));
548548

549-
let app_exe_name = settings.main_binary_name().to_string();
550-
data.insert("app_exe_name", to_json(app_exe_name));
549+
// Note: `main_binary_name` is not used in our template but we keep it as it is potentially useful for custom temples
550+
let main_binary_name = settings.main_binary_name().to_string();
551+
data.insert("main_binary_name", to_json(&main_binary_name));
551552

552553
let binaries = generate_binaries_data(settings)?;
553554

crates/tauri-bundler/src/bundle/windows/templates/installer.nsi

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,15 @@ Section Install
636636
WriteRegStr SHCTX "${UNINSTKEY}" $MultiUser.InstallMode 1
637637
!endif
638638

639+
; Remove old main binary if it doesn't match new main binary name
640+
ReadRegStr $0 SHCTX "${UNINSTKEY}" "MainBinaryName"
641+
${If} $0 != "${MAINBINARYNAME}.exe"
642+
Delete "$INSTDIR\$0"
643+
${EndIf}
644+
645+
; Save current MAINBINARYNAME for future updates
646+
WriteRegStr SHCTX "${UNINSTKEY}" "MainBinaryName" "${MAINBINARYNAME}.exe"
647+
639648
; Registry information for add/remove programs
640649
WriteRegStr SHCTX "${UNINSTKEY}" "DisplayName" "${PRODUCTNAME}"
641650
WriteRegStr SHCTX "${UNINSTKEY}" "DisplayIcon" "$\"$INSTDIR\${MAINBINARYNAME}.exe$\""

0 commit comments

Comments
 (0)