mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-08-11 18:40:22 +02:00
fix(core/updater): check if installer args are not empty before passing -ArgumentList (#818)
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
"updater": "patch"
|
||||||
|
"updater-js": "patch"
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix NSIS updater failing to launch when using `basicUi` mode.
|
||||||
@@ -496,31 +496,32 @@ impl Update {
|
|||||||
// If it's an `exe` we expect an installer not a runtime.
|
// If it's an `exe` we expect an installer not a runtime.
|
||||||
if found_path.extension() == Some(OsStr::new("exe")) {
|
if found_path.extension() == Some(OsStr::new("exe")) {
|
||||||
// we need to wrap the installer path in quotes for Start-Process
|
// we need to wrap the installer path in quotes for Start-Process
|
||||||
let mut installer_arg = std::ffi::OsString::new();
|
let mut installer_path = std::ffi::OsString::new();
|
||||||
installer_arg.push("\"");
|
installer_path.push("\"");
|
||||||
installer_arg.push(&found_path);
|
installer_path.push(&found_path);
|
||||||
installer_arg.push("\"");
|
installer_path.push("\"");
|
||||||
|
|
||||||
|
let installer_args = [
|
||||||
|
self.config.windows.install_mode.nsis_args(),
|
||||||
|
self.installer_args
|
||||||
|
.iter()
|
||||||
|
.map(AsRef::as_ref)
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
.as_slice(),
|
||||||
|
]
|
||||||
|
.concat();
|
||||||
|
|
||||||
// Run the installer
|
// Run the installer
|
||||||
Command::new(powershell_path)
|
let mut cmd = Command::new(powershell_path);
|
||||||
.args(["-NoProfile", "-WindowStyle", "Hidden"])
|
|
||||||
|
cmd.args(["-NoProfile", "-WindowStyle", "Hidden"])
|
||||||
.args(["Start-Process"])
|
.args(["Start-Process"])
|
||||||
.arg(installer_arg)
|
.arg(installer_path);
|
||||||
.arg("-ArgumentList")
|
|
||||||
.arg(
|
if !installer_args.is_empty() {
|
||||||
[
|
cmd.arg("-ArgumentList").arg(installer_args.join(", "));
|
||||||
self.config.windows.install_mode.nsis_args(),
|
}
|
||||||
self.installer_args
|
cmd.spawn().expect("installer failed to start");
|
||||||
.iter()
|
|
||||||
.map(AsRef::as_ref)
|
|
||||||
.collect::<Vec<_>>()
|
|
||||||
.as_slice(),
|
|
||||||
]
|
|
||||||
.concat()
|
|
||||||
.join(", "),
|
|
||||||
)
|
|
||||||
.spawn()
|
|
||||||
.expect("installer failed to start");
|
|
||||||
|
|
||||||
std::process::exit(0);
|
std::process::exit(0);
|
||||||
} else if found_path.extension() == Some(OsStr::new("msi")) {
|
} else if found_path.extension() == Some(OsStr::new("msi")) {
|
||||||
@@ -530,19 +531,20 @@ impl Update {
|
|||||||
current_exe_arg.push(current_exe()?);
|
current_exe_arg.push(current_exe()?);
|
||||||
current_exe_arg.push("\"");
|
current_exe_arg.push("\"");
|
||||||
|
|
||||||
let mut msi_path_arg = std::ffi::OsString::new();
|
let mut msi_path = std::ffi::OsString::new();
|
||||||
msi_path_arg.push("\"\"\"");
|
msi_path.push("\"\"\"");
|
||||||
msi_path_arg.push(&found_path);
|
msi_path.push(&found_path);
|
||||||
msi_path_arg.push("\"\"\"");
|
msi_path.push("\"\"\"");
|
||||||
|
|
||||||
let msiexec_args = self
|
let installer_args = [
|
||||||
.config
|
self.config.windows.install_mode.msiexec_args(),
|
||||||
.windows
|
self.installer_args
|
||||||
.install_mode
|
.iter()
|
||||||
.msiexec_args()
|
.map(AsRef::as_ref)
|
||||||
.iter()
|
.collect::<Vec<_>>()
|
||||||
.map(|p| p.to_string())
|
.as_slice(),
|
||||||
.collect::<Vec<String>>();
|
]
|
||||||
|
.concat();
|
||||||
|
|
||||||
// run the installer and relaunch the application
|
// run the installer and relaunch the application
|
||||||
let powershell_install_res = Command::new(powershell_path)
|
let powershell_install_res = Command::new(powershell_path)
|
||||||
@@ -551,12 +553,12 @@ impl Update {
|
|||||||
"Start-Process",
|
"Start-Process",
|
||||||
"-Wait",
|
"-Wait",
|
||||||
"-FilePath",
|
"-FilePath",
|
||||||
"$env:SYSTEMROOT\\System32\\msiexec.exe",
|
"$Env:SYSTEMROOT\\System32\\msiexec.exe",
|
||||||
"-ArgumentList",
|
"-ArgumentList",
|
||||||
])
|
])
|
||||||
.arg("/i,")
|
.arg("/i,")
|
||||||
.arg(&msi_path_arg)
|
.arg(&msi_path)
|
||||||
.arg(format!(", {}, /promptrestart;", msiexec_args.join(", ")))
|
.arg(format!(", {}, /promptrestart;", installer_args.join(", ")))
|
||||||
.arg("Start-Process")
|
.arg("Start-Process")
|
||||||
.arg(current_exe_arg)
|
.arg(current_exe_arg)
|
||||||
.spawn();
|
.spawn();
|
||||||
@@ -569,8 +571,8 @@ impl Update {
|
|||||||
);
|
);
|
||||||
let _ = Command::new(msiexec_path)
|
let _ = Command::new(msiexec_path)
|
||||||
.arg("/i")
|
.arg("/i")
|
||||||
.arg(msi_path_arg)
|
.arg(msi_path)
|
||||||
.args(msiexec_args)
|
.args(installer_args)
|
||||||
.arg("/promptrestart")
|
.arg("/promptrestart")
|
||||||
.spawn();
|
.spawn();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user