diff --git a/.changes/escape-nsis-resource-sidecar.md b/.changes/escape-nsis-resource-sidecar.md new file mode 100644 index 000000000..51bca3685 --- /dev/null +++ b/.changes/escape-nsis-resource-sidecar.md @@ -0,0 +1,5 @@ +--- +tauri-bundler: patch:bug +--- + +Fix NSIS bundler can't include resources and sidecars with `$` in the path diff --git a/crates/tauri-bundler/src/bundle/windows/nsis/installer.nsi b/crates/tauri-bundler/src/bundle/windows/nsis/installer.nsi index c960eeb14..47ca20f0c 100644 --- a/crates/tauri-bundler/src/bundle/windows/nsis/installer.nsi +++ b/crates/tauri-bundler/src/bundle/windows/nsis/installer.nsi @@ -630,12 +630,12 @@ Section Install CreateDirectory "$INSTDIR\\{{this}}" {{/each}} {{#each resources}} - File /a "/oname={{this.[1]}}" "{{@key}}" + File /a "/oname={{this.[1]}}" "{{no-escape @key}}" {{/each}} ; Copy external binaries {{#each binaries}} - File /a "/oname={{this}}" "{{@key}}" + File /a "/oname={{this}}" "{{no-escape @key}}" {{/each}} ; Create file associations diff --git a/crates/tauri-bundler/src/bundle/windows/nsis/mod.rs b/crates/tauri-bundler/src/bundle/windows/nsis/mod.rs index 7dd1a26cc..7c94ffbf7 100644 --- a/crates/tauri-bundler/src/bundle/windows/nsis/mod.rs +++ b/crates/tauri-bundler/src/bundle/windows/nsis/mod.rs @@ -467,6 +467,7 @@ fn build_nsis_app_installer( let mut handlebars = Handlebars::new(); handlebars.register_helper("or", Box::new(handlebars_or)); handlebars.register_helper("association-description", Box::new(association_description)); + handlebars.register_helper("no-escape", Box::new(handlebars_no_escape)); handlebars.register_escape_fn(|s| { let mut output = String::new(); for c in s.chars() { @@ -595,6 +596,24 @@ fn association_description( Ok(()) } +fn handlebars_no_escape( + h: &handlebars::Helper<'_>, + _: &Handlebars<'_>, + _: &handlebars::Context, + _: &mut handlebars::RenderContext<'_, '_>, + out: &mut dyn handlebars::Output, +) -> handlebars::HelperResult { + // get parameter from helper or throw an error + let param = h + .param(0) + .ok_or(handlebars::RenderErrorReason::ParamNotFoundForIndex( + "no-escape", + 0, + ))?; + write!(out, "{}", param.render())?; + Ok(()) +} + /// BTreeMap type ResourcesMap = BTreeMap; fn generate_resource_data(settings: &Settings) -> crate::Result {