diff --git a/cli/tauri-cli/Cargo.toml b/cli/tauri-cli/Cargo.toml
index e7c1f059d..3a5b1edf6 100644
--- a/cli/tauri-cli/Cargo.toml
+++ b/cli/tauri-cli/Cargo.toml
@@ -33,6 +33,7 @@ toml = "0.5.5"
uuid = { version = "0.8", features = ["v5"] }
walkdir = "2"
+[target.'cfg(target_os = "windows")'.dependencies]
attohttpc = { version = "0.7.0" }
[target.'cfg(not(target_os = "linux"))'.dependencies]
diff --git a/cli/tauri-cli/src/bundle/templates/main.wxs b/cli/tauri-cli/src/bundle/templates/main.wxs
index 352ede3b3..df0aa492e 100644
--- a/cli/tauri-cli/src/bundle/templates/main.wxs
+++ b/cli/tauri-cli/src/bundle/templates/main.wxs
@@ -21,17 +21,21 @@
+
+
+
-
-
-
+
+
+
+
@@ -43,16 +47,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
\ No newline at end of file
diff --git a/cli/tauri-cli/src/bundle/wix.rs b/cli/tauri-cli/src/bundle/wix.rs
index d647f68c5..f77700308 100644
--- a/cli/tauri-cli/src/bundle/wix.rs
+++ b/cli/tauri-cli/src/bundle/wix.rs
@@ -1,5 +1,7 @@
use super::common;
+use super::path_utils::{copy, Options};
use super::settings::Settings;
+
use handlebars::Handlebars;
use lazy_static::lazy_static;
use sha2::Digest;
@@ -44,11 +46,42 @@ lazy_static! {
handlebars
.register_template_string("main.wxs", include_str!("templates/main.wxs"))
+ .or_else(|e| Err(e.to_string()))
.unwrap();
handlebars
};
}
+fn copy_icons(settings: &Settings) -> crate::Result {
+ let base_dir = settings.binary_path();
+ let base_dir = base_dir.parent().expect("Failed to get dir");
+
+ let resource_dir = base_dir.join("resources");
+
+ let mut image_path = PathBuf::from(settings.project_out_directory());
+
+ // 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,
+ overwrite: true,
+ ..opts
+ },
+ )
+ .or_else(|e| Err(e.to_string()))?;
+
+ Ok(resource_dir)
+}
+
// Function used to download Wix and VC_REDIST. Checks SHA256 to verify the download.
fn download_and_verify(url: &str, hash: &str) -> crate::Result> {
common::print_info(format!("Downloading {}", url).as_str())?;
@@ -322,6 +355,9 @@ pub fn build_wix_app_installer(
let path_guid = generate_package_guid(settings).to_string();
data.insert("path_component_guid", &path_guid.as_str());
+ let shortcut_guid = generate_package_guid(settings).to_string();
+ data.insert("shortcut_guid", &shortcut_guid.as_str());
+
let app_exe_name = settings.binary_name().to_string();
data.insert("app_exe_name", &app_exe_name);
@@ -329,11 +365,12 @@ pub fn build_wix_app_installer(
data.insert("app_exe_source", &app_exe_source);
- let image_path = PathBuf::from("../../../../icons/icon.ico")
- .display()
- .to_string();
+ // copy icons from icons folder to resource folder near msi
+ let image_path = copy_icons(&settings)?;
- data.insert("icon_path", &image_path);
+ let path = image_path.join("icon.ico").display().to_string();
+
+ data.insert("icon_path", path.as_str());
let temp = HANDLEBARS
.render("main.wxs", &data)
diff --git a/cli/tauri-cli/src/main.rs b/cli/tauri-cli/src/main.rs
index e0c52576f..71f8586b3 100644
--- a/cli/tauri-cli/src/main.rs
+++ b/cli/tauri-cli/src/main.rs
@@ -27,7 +27,7 @@ error_chain! {
Term(::term::Error);
Toml(::toml::de::Error);
Walkdir(::walkdir::Error);
- HttpError(::attohttpc::Error);
+ HttpError(::attohttpc::Error) #[cfg(windows)];
StripError(std::path::StripPrefixError);
}
diff --git a/cli/tauri.js/templates/src-tauri/Cargo.toml b/cli/tauri.js/templates/src-tauri/Cargo.toml
index 0f8fafe0f..67f4a2437 100755
--- a/cli/tauri.js/templates/src-tauri/Cargo.toml
+++ b/cli/tauri.js/templates/src-tauri/Cargo.toml
@@ -7,18 +7,20 @@ license = ""
repository = ""
default-run = "app"
edition = "2018"
+build = "src/build.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
serde_json = "1.0.41"
-serde = "1.0"
-serde_derive = "1.0"
+serde = "1.0.104"
+serde_derive = "1.0.104"
tiny_http = "0.6"
-phf = "0.7.24"
-includedir = "0.5.0"
tauri = <%= tauriDep || `{ version = "0.2.0" }` %>
+[target."cfg(windows)".build-dependencies]
+winres = "0.1"
+
[features]
dev-server = [ "tauri/dev-server" ]
embedded-server = [ "tauri/embedded-server" ]
diff --git a/cli/tauri.js/templates/src-tauri/src/build.rs b/cli/tauri.js/templates/src-tauri/src/build.rs
new file mode 100644
index 000000000..fcd568038
--- /dev/null
+++ b/cli/tauri.js/templates/src-tauri/src/build.rs
@@ -0,0 +1,12 @@
+#[cfg(windows)]
+extern crate winres;
+
+#[cfg(windows)]
+fn main() {
+ let mut res = winres::WindowsResource::new();
+ res.set_icon("icons/icon.ico");
+ res.compile().expect("Unable to find visual studio tools");
+}
+
+#[cfg(not(windows))]
+fn main() {}