|
2 | 2 | // SPDX-License-Identifier: Apache-2.0 |
3 | 3 | // SPDX-License-Identifier: MIT |
4 | 4 |
|
5 | | -#[cfg(target_os = "windows")] |
6 | 5 | use crate::bundle::windows::sign::{sign_command, try_sign}; |
| 6 | + |
7 | 7 | use crate::{ |
8 | 8 | bundle::{ |
9 | 9 | common::CommandExt, |
@@ -67,6 +67,7 @@ pub fn bundle_project(settings: &Settings, updater: bool) -> crate::Result<Vec<P |
67 | 67 | let nsis_toolset_path = tauri_tools_path.join("NSIS"); |
68 | 68 |
|
69 | 69 | if !nsis_toolset_path.exists() { |
| 70 | + create_dir_all(&nsis_toolset_path)?; |
70 | 71 | get_and_extract_nsis(&nsis_toolset_path, &tauri_tools_path)?; |
71 | 72 | } else if NSIS_REQUIRED_FILES |
72 | 73 | .iter() |
@@ -114,12 +115,10 @@ fn get_and_extract_nsis(nsis_toolset_path: &Path, _tauri_tools_path: &Path) -> c |
114 | 115 | NSIS_TAURI_UTILS_SHA1, |
115 | 116 | HashAlgorithm::Sha1, |
116 | 117 | )?; |
117 | | - write( |
118 | | - nsis_plugins |
119 | | - .join("x86-unicode") |
120 | | - .join("nsis_tauri_utils.dll"), |
121 | | - data, |
122 | | - )?; |
| 118 | + |
| 119 | + let target_folder = nsis_plugins.join("x86-unicode"); |
| 120 | + create_dir_all(&target_folder)?; |
| 121 | + write(target_folder.join("nsis_tauri_utils.dll"), data)?; |
123 | 122 |
|
124 | 123 | Ok(()) |
125 | 124 | } |
@@ -163,9 +162,6 @@ fn build_nsis_app_installer( |
163 | 162 |
|
164 | 163 | log::info!("Target: {}", arch); |
165 | 164 |
|
166 | | - #[cfg(not(target_os = "windows"))] |
167 | | - log::info!("Code signing is currently only supported on Windows hosts, skipping..."); |
168 | | - |
169 | 165 | let output_path = settings.project_out_directory().join("nsis").join(arch); |
170 | 166 | if output_path.exists() { |
171 | 167 | remove_dir_all(&output_path)?; |
@@ -197,16 +193,9 @@ fn build_nsis_app_installer( |
197 | 193 | ); |
198 | 194 | data.insert("copyright", to_json(settings.copyright_string())); |
199 | 195 |
|
200 | | - // Code signing is currently only supported on Windows hosts |
201 | | - #[cfg(target_os = "windows")] |
202 | 196 | if settings.can_sign() { |
203 | | - data.insert( |
204 | | - "uninstaller_sign_cmd", |
205 | | - to_json(format!( |
206 | | - "{:?}", |
207 | | - sign_command("%1", &settings.sign_params())?.0 |
208 | | - )), |
209 | | - ); |
| 197 | + let sign_cmd = format!("{:?}", sign_command("%1", &settings.sign_params())?); |
| 198 | + data.insert("uninstaller_sign_cmd", to_json(sign_cmd)); |
210 | 199 | } |
211 | 200 |
|
212 | 201 | let version = settings.version_string(); |
@@ -517,9 +506,12 @@ fn build_nsis_app_installer( |
517 | 506 |
|
518 | 507 | rename(nsis_output_path, &nsis_installer_path)?; |
519 | 508 |
|
520 | | - // Code signing is currently only supported on Windows hosts |
521 | | - #[cfg(target_os = "windows")] |
522 | | - try_sign(&nsis_installer_path, settings)?; |
| 509 | + if settings.can_sign() { |
| 510 | + try_sign(&nsis_installer_path, settings)?; |
| 511 | + } else { |
| 512 | + #[cfg(not(target_os = "windows"))] |
| 513 | + log::warn!("Signing, by default, is only supported on Windows hosts, but you can specify a custom signing command in `bundler > windows > sign_command`, for now, skipping signing the installer..."); |
| 514 | + } |
523 | 515 |
|
524 | 516 | Ok(vec![nsis_installer_path]) |
525 | 517 | } |
|
0 commit comments