Skip to content

Commit

Permalink
fix(bundler): Fix nsis resource paths on non-windows build systems. (#…
Browse files Browse the repository at this point in the history
…9281)

* fix(bundler): Fix nsis resource paths on non-windows build systems.

* remove leftover from alternative
  • Loading branch information
FabianLars committed Mar 26, 2024
1 parent 77cc49a commit 017861e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changes/bundler-resources-unix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'tauri-bundler': 'patch:bug'
---

Fixed an issue causing the NSIS bundler to install resources incorrectly when the installer was built on a non-Windows system.
25 changes: 25 additions & 0 deletions tooling/bundler/src/bundle/windows/nsis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,31 @@ fn build_nsis_app_installer(
resources_ancestors.sort_by_key(|p| std::cmp::Reverse(p.components().count()));
resources_ancestors.pop(); // Last one is always ""

// We need to convert / to \ for nsis to move the files into the correct dirs
#[cfg(not(target_os = "windows"))]
let resources: ResourcesMap = resources
.into_iter()
.map(|(r, p)| {
(
r,
(
p.0.display().to_string().replace('/', "\\").into(),
p.1.display().to_string().replace('/', "\\").into(),
),
)
})
.collect();
#[cfg(not(target_os = "windows"))]
let resources_ancestors: Vec<PathBuf> = resources_ancestors
.into_iter()
.map(|p| p.display().to_string().replace('/', "\\").into())
.collect();
#[cfg(not(target_os = "windows"))]
let resources_dirs: Vec<PathBuf> = resources_dirs
.into_iter()
.map(|p| p.display().to_string().replace('/', "\\").into())
.collect();

data.insert("resources_ancestors", to_json(resources_ancestors));
data.insert("resources_dirs", to_json(resources_dirs));
data.insert("resources", to_json(&resources));
Expand Down

0 comments on commit 017861e

Please sign in to comment.