Skip to content

Commit 9ea7650

Browse files
fix(nsis): can't include resources with $ (#13186)
1 parent bb5faa2 commit 9ea7650

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
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:bug
3+
---
4+
5+
Fix NSIS bundler can't include resources and sidecars with `$` in the path

crates/tauri-bundler/src/bundle/windows/nsis/installer.nsi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,12 +630,12 @@ Section Install
630630
CreateDirectory "$INSTDIR\\{{this}}"
631631
{{/each}}
632632
{{#each resources}}
633-
File /a "/oname={{this.[1]}}" "{{@key}}"
633+
File /a "/oname={{this.[1]}}" "{{no-escape @key}}"
634634
{{/each}}
635635

636636
; Copy external binaries
637637
{{#each binaries}}
638-
File /a "/oname={{this}}" "{{@key}}"
638+
File /a "/oname={{this}}" "{{no-escape @key}}"
639639
{{/each}}
640640

641641
; Create file associations

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,7 @@ fn build_nsis_app_installer(
467467
let mut handlebars = Handlebars::new();
468468
handlebars.register_helper("or", Box::new(handlebars_or));
469469
handlebars.register_helper("association-description", Box::new(association_description));
470+
handlebars.register_helper("no-escape", Box::new(handlebars_no_escape));
470471
handlebars.register_escape_fn(|s| {
471472
let mut output = String::new();
472473
for c in s.chars() {
@@ -595,6 +596,24 @@ fn association_description(
595596
Ok(())
596597
}
597598

599+
fn handlebars_no_escape(
600+
h: &handlebars::Helper<'_>,
601+
_: &Handlebars<'_>,
602+
_: &handlebars::Context,
603+
_: &mut handlebars::RenderContext<'_, '_>,
604+
out: &mut dyn handlebars::Output,
605+
) -> handlebars::HelperResult {
606+
// get parameter from helper or throw an error
607+
let param = h
608+
.param(0)
609+
.ok_or(handlebars::RenderErrorReason::ParamNotFoundForIndex(
610+
"no-escape",
611+
0,
612+
))?;
613+
write!(out, "{}", param.render())?;
614+
Ok(())
615+
}
616+
598617
/// BTreeMap<OriginalPath, (ParentOfTargetPath, TargetPath)>
599618
type ResourcesMap = BTreeMap<PathBuf, (PathBuf, PathBuf)>;
600619
fn generate_resource_data(settings: &Settings) -> crate::Result<ResourcesMap> {

0 commit comments

Comments
 (0)