From cf771bf69aa26b62d11a54a69131c631505d8c55 Mon Sep 17 00:00:00 2001 From: Fabian-Lars Date: Fri, 17 Jan 2025 16:41:31 +0100 Subject: [PATCH] fix(bundler/wix): Prevent dlls from overwriting root resources (#12402) --- .changes/fix-bundler-wix-dlls.md | 5 +++++ crates/tauri-bundler/src/bundle/windows/msi/mod.rs | 11 ++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 .changes/fix-bundler-wix-dlls.md diff --git a/.changes/fix-bundler-wix-dlls.md b/.changes/fix-bundler-wix-dlls.md new file mode 100644 index 000000000000..bbe9063a130a --- /dev/null +++ b/.changes/fix-bundler-wix-dlls.md @@ -0,0 +1,5 @@ +--- +tauri-bundler: 'patch:bug' +--- + +Fixed an issue that caused the .msi installer to not contain root resources when there were .dll files present in the target directory. diff --git a/crates/tauri-bundler/src/bundle/windows/msi/mod.rs b/crates/tauri-bundler/src/bundle/windows/msi/mod.rs index 6eef04fae0f1..c3d4cd6ac25d 100644 --- a/crates/tauri-bundler/src/bundle/windows/msi/mod.rs +++ b/crates/tauri-bundler/src/bundle/windows/msi/mod.rs @@ -1040,6 +1040,7 @@ fn generate_resource_data(settings: &Settings) -> crate::Result { let mut dlls = Vec::new(); + // TODO: The bundler should not include all DLLs it finds. Instead it should only include WebView2Loader.dll if present and leave the rest to the resources config. let out_dir = settings.project_out_directory(); for dll in glob::glob( &PathBuf::from(glob::Pattern::escape(&out_dir.to_string_lossy())) @@ -1063,15 +1064,15 @@ fn generate_resource_data(settings: &Settings) -> crate::Result { } if !dlls.is_empty() { - resources.insert( - "".to_string(), - ResourceDirectory { + resources + .entry("".to_string()) + .and_modify(|r| r.files.append(&mut dlls)) + .or_insert(ResourceDirectory { path: "".to_string(), name: "".to_string(), directories: vec![], files: dlls, - }, - ); + }); } Ok(resources)