From 3ce619d5956a3781c207bbba61e13da4840a191d Mon Sep 17 00:00:00 2001 From: amrbashir Date: Wed, 11 Sep 2024 19:27:19 +0300 Subject: [PATCH 1/4] fix(bundler): store and remove old main binary on updates if main binary name has change --- Cargo.lock | 1 + .../src/bundle/windows/msi/wix.rs | 4 +-- .../bundle/windows/templates/installer.nsi | 9 +++++++ .../src/bundle/windows/templates/main.wxs | 25 +++++++++++++++++++ 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9e0825f8de65..c573557e5bee 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7120,6 +7120,7 @@ dependencies = [ "thiserror", "time", "ureq", + "url", "uuid", "walkdir", "windows-registry", diff --git a/crates/tauri-bundler/src/bundle/windows/msi/wix.rs b/crates/tauri-bundler/src/bundle/windows/msi/wix.rs index 7e0f6d2b82b2..79736f757b9d 100644 --- a/crates/tauri-bundler/src/bundle/windows/msi/wix.rs +++ b/crates/tauri-bundler/src/bundle/windows/msi/wix.rs @@ -540,8 +540,8 @@ 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)); + let main_binary_name = settings.main_binary_name().to_string(); + data.insert("main_binary_name", to_json(&main_binary_name)); let binaries = generate_binaries_data(settings)?; diff --git a/crates/tauri-bundler/src/bundle/windows/templates/installer.nsi b/crates/tauri-bundler/src/bundle/windows/templates/installer.nsi index c6e728c66dde..35cede30caad 100644 --- a/crates/tauri-bundler/src/bundle/windows/templates/installer.nsi +++ b/crates/tauri-bundler/src/bundle/windows/templates/installer.nsi @@ -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" + ${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$\"" diff --git a/crates/tauri-bundler/src/bundle/windows/templates/main.wxs b/crates/tauri-bundler/src/bundle/windows/templates/main.wxs index 047b0926e1a4..6b20cf1631d0 100644 --- a/crates/tauri-bundler/src/bundle/windows/templates/main.wxs +++ b/crates/tauri-bundler/src/bundle/windows/templates/main.wxs @@ -75,6 +75,15 @@ + + + + + @@ -124,6 +133,10 @@ + + + + {{#each deep_link_protocols as |protocol| ~}} @@ -341,7 +354,19 @@ {{/if}} + + + + + "{{main_binary_name}}")]]> + AUTOLAUNCHAPP AND NOT Installed From ce11113ad082f7ee208758fe9c4bcbe7f43e1b27 Mon Sep 17 00:00:00 2001 From: amrbashir Date: Wed, 11 Sep 2024 19:32:51 +0300 Subject: [PATCH 2/4] change file --- .changes/store-main-binary-name.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changes/store-main-binary-name.md diff --git a/.changes/store-main-binary-name.md b/.changes/store-main-binary-name.md new file mode 100644 index 000000000000..4f60f535cf78 --- /dev/null +++ b/.changes/store-main-binary-name.md @@ -0,0 +1,6 @@ +--- +"tauri-bundler": "patch:feat" +--- + +Store main binary name in registry and delete old main binary on updates if the name changes. + From a497a393fb07e9534f38b7bd9e57627f85cb3b08 Mon Sep 17 00:00:00 2001 From: amrbashir Date: Thu, 12 Sep 2024 02:25:47 +0300 Subject: [PATCH 3/4] revert WiX changes as they are not needed and fixed by #10967 instead --- .changes/store-main-binary-name.md | 2 +- .../src/bundle/windows/templates/main.wxs | 25 ------------------- 2 files changed, 1 insertion(+), 26 deletions(-) diff --git a/.changes/store-main-binary-name.md b/.changes/store-main-binary-name.md index 4f60f535cf78..fff3fb793b53 100644 --- a/.changes/store-main-binary-name.md +++ b/.changes/store-main-binary-name.md @@ -2,5 +2,5 @@ "tauri-bundler": "patch:feat" --- -Store main binary name in registry and delete old main binary on updates if the name changes. +Store main binary name in registry for NSIS installer and delete old main binary on updates if the name changes. diff --git a/crates/tauri-bundler/src/bundle/windows/templates/main.wxs b/crates/tauri-bundler/src/bundle/windows/templates/main.wxs index 6b20cf1631d0..047b0926e1a4 100644 --- a/crates/tauri-bundler/src/bundle/windows/templates/main.wxs +++ b/crates/tauri-bundler/src/bundle/windows/templates/main.wxs @@ -75,15 +75,6 @@ - - - - - @@ -133,10 +124,6 @@ - - - - {{#each deep_link_protocols as |protocol| ~}} @@ -354,19 +341,7 @@ {{/if}} - - - - - "{{main_binary_name}}")]]> - AUTOLAUNCHAPP AND NOT Installed From 681bd39d6250d9da9169f08f266eda7546a33ae7 Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Fri, 13 Sep 2024 16:08:21 +0300 Subject: [PATCH 4/4] comment [skip ci] --- crates/tauri-bundler/src/bundle/windows/msi/wix.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/tauri-bundler/src/bundle/windows/msi/wix.rs b/crates/tauri-bundler/src/bundle/windows/msi/wix.rs index 54be2ae2f1e1..2fcc2580ac37 100644 --- a/crates/tauri-bundler/src/bundle/windows/msi/wix.rs +++ b/crates/tauri-bundler/src/bundle/windows/msi/wix.rs @@ -540,6 +540,7 @@ 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())); + // 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));