浏览代码

fix(bundler): wix installer icon path, closes #1003 (#1254)

* fix(bundler): wix installer icon path, closes #1003

* fix: build
Lucas Fernandes Nogueira 4 年之前
父节点
当前提交
f51801f790
共有 2 个文件被更改,包括 19 次插入28 次删除
  1. 16 25
      cli/tauri-bundler/src/bundle/wix.rs
  2. 3 3
      tauri/examples/api/src-tauri/Cargo.lock

+ 16 - 25
cli/tauri-bundler/src/bundle/wix.rs

@@ -1,6 +1,6 @@
 use super::{
   common,
-  path_utils::{copy, Options},
+  path_utils::{copy_file, FileOpts},
   settings::Settings,
 };
 
@@ -141,34 +141,27 @@ impl ResourceDirectory {
   }
 }
 
-/// Copies the icons to the binary path, under the `resources` folder,
-/// and returns the path to that directory.
-fn copy_icons(settings: &Settings) -> crate::Result<PathBuf> {
+/// Copies the icon to the binary path, under the `resources` folder,
+/// and returns the path to the file.
+fn copy_icon(settings: &Settings) -> crate::Result<PathBuf> {
   let base_dir = settings.project_out_directory();
 
   let resource_dir = base_dir.join("resources");
+  std::fs::create_dir_all(&resource_dir)?;
+  let icon_target_path = resource_dir.join("icon.ico");
 
-  let mut image_path = PathBuf::from(settings.project_out_directory());
+  let icon_path = std::env::current_dir()?.join("icons").join("icon.ico");
 
-  // pop off till in tauri_src dir
-  image_path.pop();
-  image_path.pop();
-
-  // get icon dir and icon file.
-  let image_path = image_path.join("icons");
-  let opts = super::path_utils::Options::default();
-
-  copy(
-    image_path,
-    &resource_dir,
-    &Options {
-      copy_files: true,
+  copy_file(
+    icon_path,
+    &icon_target_path,
+    &FileOpts {
       overwrite: true,
-      ..opts
+      ..Default::default()
     },
   )?;
 
-  Ok(resource_dir)
+  Ok(icon_target_path)
 }
 
 /// Function used to download Wix and VC_REDIST. Checks SHA256 to verify the download.
@@ -502,12 +495,10 @@ pub fn build_wix_app_installer(
 
   data.insert("app_exe_source", to_json(&app_exe_source));
 
-  // copy icons from icons folder to resource folder near msi
-  let image_path = copy_icons(&settings)?;
-
-  let path = image_path.join("icon.ico").display().to_string();
+  // copy icon from $CWD/icons/icon.ico folder to resource folder near msi
+  let icon_path = copy_icon(&settings)?;
 
-  data.insert("icon_path", to_json(path.as_str()));
+  data.insert("icon_path", to_json(icon_path));
 
   let temp = HANDLEBARS.render("main.wxs", &data)?;
 

+ 3 - 3
tauri/examples/api/src-tauri/Cargo.lock

@@ -3601,7 +3601,7 @@ dependencies = [
 [[package]]
 name = "wry"
 version = "0.4.1"
-source = "git+https://github.com/tauri-apps/wry?rev=af07c28503e41a0a164cb7256fa0ec938d5daee4#af07c28503e41a0a164cb7256fa0ec938d5daee4"
+source = "git+https://github.com/tauri-apps/wry?rev=e6cc7f0825220a0117827b6f0a366f60ce7420ea#e6cc7f0825220a0117827b6f0a366f60ce7420ea"
 dependencies = [
  "cc",
  "cocoa",
@@ -3687,9 +3687,9 @@ checksum = "b07db065a5cf61a7e4ba64f29e67db906fb1787316516c4e6e5ff0fea1efcd8a"
 
 [[package]]
 name = "zip"
-version = "0.5.9"
+version = "0.5.10"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cc2896475a242c41366941faa27264df2cb935185a92e059a004d0048feb2ac5"
+checksum = "5a8977234acab718eb2820494b2f96cbb16004c19dddf88b7445b27381450997"
 dependencies = [
  "byteorder",
  "bzip2",