feat(bundler): use known Id for the sidecar files on WiX, ref #4546 (#4658)

This commit is contained in:
Lucas Fernandes Nogueira 2022-07-12 16:55:37 -03:00 committed by GitHub
parent 261d1bc9d4
commit 597c98203c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 4 deletions

View File

@ -0,0 +1,5 @@
---
"tauri-bundler": patch
---
Use `Bin_${sidecarFilename}` as the `Id` of sidecar file on WiX so you can reference it in your WiX fragments.

View File

@ -853,6 +853,7 @@ fn generate_binaries_data(settings: &Settings) -> crate::Result<Vec<Binary>> {
let mut binaries = Vec::new();
let cwd = std::env::current_dir()?;
let tmp_dir = std::env::temp_dir();
let regex = Regex::new(r"[^\w\d\.]")?;
for src in settings.external_binaries() {
let src = src?;
let binary_path = cwd.join(&src);
@ -861,7 +862,7 @@ fn generate_binaries_data(settings: &Settings) -> crate::Result<Vec<Binary>> {
.expect("failed to extract external binary filename")
.to_string_lossy()
.replace(&format!("-{}", settings.target()), "");
let dest = tmp_dir.join(dest_filename);
let dest = tmp_dir.join(&dest_filename);
std::fs::copy(binary_path, &dest)?;
binaries.push(Binary {
@ -870,7 +871,9 @@ fn generate_binaries_data(settings: &Settings) -> crate::Result<Vec<Binary>> {
.into_os_string()
.into_string()
.expect("failed to read external binary path"),
id: format!("I{}", Uuid::new_v4().as_simple()),
id: regex
.replace_all(&dest_filename.replace('-', "_"), "")
.to_string(),
});
}
@ -883,7 +886,9 @@ fn generate_binaries_data(settings: &Settings) -> crate::Result<Vec<Binary>> {
.into_os_string()
.into_string()
.expect("failed to read binary path"),
id: format!("I{}", Uuid::new_v4().as_simple()),
id: regex
.replace_all(&bin.name().replace('-', "_"), "")
.to_string(),
})
}
}

View File

@ -116,7 +116,7 @@
</Component>
{{#each binaries as |bin| ~}}
<Component Id="{{ bin.id }}" Guid="{{bin.guid}}" Win64="$(var.Win64)">
<File Id="Path_{{ bin.id }}" Source="{{bin.path}}" KeyPath="yes"/>
<File Id="Bin_{{ bin.id }}" Source="{{bin.path}}" KeyPath="yes"/>
</Component>
{{/each~}}
{{#if enable_elevated_update_task}}