Skip to content

Commit f66bc3c

Browse files
authored
fix(bundler): DLL resources, closes #3948 (#3949)
1 parent 0198c2b commit f66bc3c

File tree

2 files changed

+40
-28
lines changed

2 files changed

+40
-28
lines changed

.changes/fix-dll-resource.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri-bundler": patch
3+
---
4+
5+
Fixes DLL resource usage on Windows.

tooling/bundler/src/bundle/windows/msi/wix.rs

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -796,34 +796,7 @@ fn generate_resource_data(settings: &Settings) -> crate::Result<ResourceMap> {
796796
let mut resources = ResourceMap::new();
797797
let cwd = std::env::current_dir()?;
798798

799-
let mut dlls = vec![];
800-
for dll in glob::glob(
801-
settings
802-
.project_out_directory()
803-
.join("*.dll")
804-
.to_string_lossy()
805-
.to_string()
806-
.as_str(),
807-
)? {
808-
let path = dll?;
809-
let resource_path = path.to_string_lossy().to_string();
810-
dlls.push(ResourceFile {
811-
id: format!("I{}", Uuid::new_v4().as_simple()),
812-
guid: Uuid::new_v4().to_string(),
813-
path: resource_path,
814-
});
815-
}
816-
if !dlls.is_empty() {
817-
resources.insert(
818-
"".to_string(),
819-
ResourceDirectory {
820-
path: "".to_string(),
821-
name: "".to_string(),
822-
directories: vec![],
823-
files: dlls,
824-
},
825-
);
826-
}
799+
let mut added_resources = Vec::new();
827800

828801
for src in settings.resource_files() {
829802
let src = src?;
@@ -834,6 +807,8 @@ fn generate_resource_data(settings: &Settings) -> crate::Result<ResourceMap> {
834807
.into_string()
835808
.expect("failed to read resource path");
836809

810+
added_resources.push(resource_path.clone());
811+
837812
let resource_entry = ResourceFile {
838813
id: format!("I{}", Uuid::new_v4().as_simple()),
839814
guid: Uuid::new_v4().to_string(),
@@ -904,5 +879,37 @@ fn generate_resource_data(settings: &Settings) -> crate::Result<ResourceMap> {
904879
directory_entry.add_file(resource_entry);
905880
}
906881

882+
let mut dlls = Vec::new();
883+
884+
let out_dir = settings.project_out_directory();
885+
for dll in glob::glob(out_dir.join("*.dll").to_string_lossy().to_string().as_str())? {
886+
let path = dll?;
887+
let resource_path = path.to_string_lossy().into_owned();
888+
let relative_path = path
889+
.strip_prefix(&out_dir)
890+
.unwrap()
891+
.to_string_lossy()
892+
.into_owned();
893+
if !added_resources.iter().any(|r| r.ends_with(&relative_path)) {
894+
dlls.push(ResourceFile {
895+
id: format!("I{}", Uuid::new_v4().as_simple()),
896+
guid: Uuid::new_v4().to_string(),
897+
path: resource_path,
898+
});
899+
}
900+
}
901+
902+
if !dlls.is_empty() {
903+
resources.insert(
904+
"".to_string(),
905+
ResourceDirectory {
906+
path: "".to_string(),
907+
name: "".to_string(),
908+
directories: vec![],
909+
files: dlls,
910+
},
911+
);
912+
}
913+
907914
Ok(resources)
908915
}

0 commit comments

Comments
 (0)