Эх сурвалжийг харах

feat(bundler): validate wix toolset files, ref #4474 (#4475)

Lucas Fernandes Nogueira 3 жил өмнө
parent
commit
956af4f30f

+ 5 - 0
.changes/validate-wixtools.md

@@ -0,0 +1,5 @@
+---
+"tauri-bundler": patch
+---
+
+Check if `$HOME\AppData\Local\tauri\WixTools` directory has all the required files and redownload WiX if something is missing.

+ 21 - 0
tooling/bundler/src/bundle/windows/msi.rs

@@ -7,9 +7,23 @@ mod wix;
 pub use wix::{MSI_FOLDER_NAME, MSI_UPDATER_FOLDER_NAME};
 
 use crate::Settings;
+use log::warn;
 
 use std::{self, path::PathBuf};
 
+const WIX_REQUIRED_FILES: &[&str] = &[
+  "candle.exe",
+  "candle.exe.config",
+  "darice.cub",
+  "light.exe",
+  "light.exe.config",
+  "wconsole.dll",
+  "winterop.dll",
+  "wix.dll",
+  "WixUIExtension.dll",
+  "WixUtilExtension.dll",
+];
+
 /// Runs all of the commands to build the MSI installer.
 /// Returns a vector of PathBuf that shows where the MSI was created.
 pub fn bundle_project(settings: &Settings, updater: bool) -> crate::Result<Vec<PathBuf>> {
@@ -18,6 +32,13 @@ pub fn bundle_project(settings: &Settings, updater: bool) -> crate::Result<Vec<P
 
   if !wix_path.exists() {
     wix::get_and_extract_wix(&wix_path)?;
+  } else if WIX_REQUIRED_FILES
+    .iter()
+    .any(|p| !wix_path.join(p).exists())
+  {
+    warn!("WixTools directory is missing some files. Recreating it.");
+    std::fs::remove_dir_all(&wix_path)?;
+    wix::get_and_extract_wix(&wix_path)?;
   }
 
   wix::build_wix_app_installer(settings, &wix_path, updater)