Skip to content

Commit 597c982

Browse files
authored
feat(bundler): use known Id for the sidecar files on WiX, ref #4546 (#4658)
1 parent 261d1bc commit 597c982

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

.changes/sidecar-wix-ids.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri-bundler": patch
3+
---
4+
5+
Use `Bin_${sidecarFilename}` as the `Id` of sidecar file on WiX so you can reference it in your WiX fragments.

tooling/bundler/src/bundle/windows/msi/wix.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,7 @@ fn generate_binaries_data(settings: &Settings) -> crate::Result<Vec<Binary>> {
853853
let mut binaries = Vec::new();
854854
let cwd = std::env::current_dir()?;
855855
let tmp_dir = std::env::temp_dir();
856+
let regex = Regex::new(r"[^\w\d\.]")?;
856857
for src in settings.external_binaries() {
857858
let src = src?;
858859
let binary_path = cwd.join(&src);
@@ -861,7 +862,7 @@ fn generate_binaries_data(settings: &Settings) -> crate::Result<Vec<Binary>> {
861862
.expect("failed to extract external binary filename")
862863
.to_string_lossy()
863864
.replace(&format!("-{}", settings.target()), "");
864-
let dest = tmp_dir.join(dest_filename);
865+
let dest = tmp_dir.join(&dest_filename);
865866
std::fs::copy(binary_path, &dest)?;
866867

867868
binaries.push(Binary {
@@ -870,7 +871,9 @@ fn generate_binaries_data(settings: &Settings) -> crate::Result<Vec<Binary>> {
870871
.into_os_string()
871872
.into_string()
872873
.expect("failed to read external binary path"),
873-
id: format!("I{}", Uuid::new_v4().as_simple()),
874+
id: regex
875+
.replace_all(&dest_filename.replace('-', "_"), "")
876+
.to_string(),
874877
});
875878
}
876879

@@ -883,7 +886,9 @@ fn generate_binaries_data(settings: &Settings) -> crate::Result<Vec<Binary>> {
883886
.into_os_string()
884887
.into_string()
885888
.expect("failed to read binary path"),
886-
id: format!("I{}", Uuid::new_v4().as_simple()),
889+
id: regex
890+
.replace_all(&bin.name().replace('-', "_"), "")
891+
.to_string(),
887892
})
888893
}
889894
}

tooling/bundler/src/bundle/windows/templates/main.wxs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
</Component>
117117
{{#each binaries as |bin| ~}}
118118
<Component Id="{{ bin.id }}" Guid="{{bin.guid}}" Win64="$(var.Win64)">
119-
<File Id="Path_{{ bin.id }}" Source="{{bin.path}}" KeyPath="yes"/>
119+
<File Id="Bin_{{ bin.id }}" Source="{{bin.path}}" KeyPath="yes"/>
120120
</Component>
121121
{{/each~}}
122122
{{#if enable_elevated_update_task}}

0 commit comments

Comments
 (0)