Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(bundler): store and remove old main binary on updates if main binary name has change #10962

Merged
merged 5 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/store-main-binary-name.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"tauri-bundler": "patch:feat"
---

Store main binary name in registry for NSIS installer and delete old main binary on updates if the name changes.

1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions crates/tauri-bundler/src/bundle/windows/msi/wix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,8 +540,9 @@ pub fn build_wix_app_installer(
let shortcut_guid = generate_package_guid(settings).to_string();
data.insert("shortcut_guid", to_json(shortcut_guid.as_str()));

let app_exe_name = settings.main_binary_name().to_string();
data.insert("app_exe_name", to_json(app_exe_name));
// Note: `main_binary_name` is not used in our template but we keep it as it is potentially useful for custom temples
let main_binary_name = settings.main_binary_name().to_string();
data.insert("main_binary_name", to_json(&main_binary_name));
amrbashir marked this conversation as resolved.
Show resolved Hide resolved
amrbashir marked this conversation as resolved.
Show resolved Hide resolved

let binaries = generate_binaries_data(settings)?;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,15 @@ Section Install
WriteRegStr SHCTX "${UNINSTKEY}" $MultiUser.InstallMode 1
!endif

; Remove old main binary if it doesn't match new main binary name
ReadRegStr $0 SHCTX "${UNINSTKEY}" "MainBinaryName"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this delete the binary on each install? since the v2 installer also uses the same key.. maybe we should use a different one for v2?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no this key will be removed when running the uninstaller, so it is only valid when doing updates. It has to be the same key for every installer (whether v1 or v2) so it can detect main binary name changes on updates

${If} $0 != "${MAINBINARYNAME}.exe"
Delete "$INSTDIR\$0"
${EndIf}

; Save current MAINBINARYNAME for future updates
WriteRegStr SHCTX "${UNINSTKEY}" "MainBinaryName" "${MAINBINARYNAME}.exe"

; Registry information for add/remove programs
WriteRegStr SHCTX "${UNINSTKEY}" "DisplayName" "${PRODUCTNAME}"
WriteRegStr SHCTX "${UNINSTKEY}" "DisplayIcon" "$\"$INSTDIR\${MAINBINARYNAME}.exe$\""
Expand Down