Skip to content

Commit 4176f93

Browse files
feat(bundler): consider extensions defined in main.wxs. (#14570)
* feat(bundler): consider extensions defined in main.wxs. * chore(bundler): apply nitpick and add a change file. * Update crates/tauri-bundler/src/bundle/windows/msi/mod.rs chore(bundler): avoid clone and use reference. Co-authored-by: Tony <[email protected]> * Update .changes/support-template-extensions.md chore(bundler): reclassify changes. Co-authored-by: Tony <[email protected]> --------- Co-authored-by: Tony <[email protected]>
1 parent 4408f72 commit 4176f93

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
tauri-bundler: patch:enhance
3+
---
4+
5+
Consider extensions that are defined in the wxs template.

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -753,26 +753,28 @@ pub fn build_wix_app_installer(
753753
}
754754

755755
let main_wxs_path = output_path.join("main.wxs");
756-
fs::write(main_wxs_path, handlebars.render("main.wxs", &data)?)?;
756+
fs::write(&main_wxs_path, handlebars.render("main.wxs", &data)?)?;
757757

758-
let mut candle_inputs = vec![("main.wxs".into(), Vec::new())];
758+
let mut candle_inputs = vec![];
759759

760760
let current_dir = std::env::current_dir()?;
761761
let extension_regex = Regex::new("\"http://schemas.microsoft.com/wix/(\\w+)\"")?;
762-
for fragment_path in fragment_paths {
763-
let fragment_path = current_dir.join(fragment_path);
764-
let fragment_content = fs::read_to_string(&fragment_path)?;
765-
let fragment_handlebars = Handlebars::new();
766-
let fragment = fragment_handlebars.render_template(&fragment_content, &data)?;
762+
let input_paths =
763+
std::iter::once(main_wxs_path).chain(fragment_paths.iter().map(|p| current_dir.join(p)));
764+
765+
for input_path in input_paths {
766+
let input_content = fs::read_to_string(&input_path)?;
767+
let input_handlebars = Handlebars::new();
768+
let input = input_handlebars.render_template(&input_content, &data)?;
767769
let mut extensions = Vec::new();
768-
for cap in extension_regex.captures_iter(&fragment) {
770+
for cap in extension_regex.captures_iter(&input) {
769771
let path = wix_toolset_path.join(format!("Wix{}.dll", &cap[1]));
770772
if settings.windows().can_sign() {
771773
try_sign(&path, settings)?;
772774
}
773775
extensions.push(path);
774776
}
775-
candle_inputs.push((fragment_path, extensions));
777+
candle_inputs.push((input_path, extensions));
776778
}
777779

778780
let mut fragment_extensions = HashSet::new();

0 commit comments

Comments
 (0)