Skip to content

Commit 645e1dc

Browse files
authored
fix(core/updater): check if installer args are not empty before passing -ArgumentList closes #8296 (#8404)
1 parent 50a3d17 commit 645e1dc

File tree

2 files changed

+53
-45
lines changed

2 files changed

+53
-45
lines changed

.changes/nsis-basicui.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'tauri': 'patch:bug'
3+
---
4+
5+
Fix NSIS updater failing to launch when using `basicUi` mode.

core/tauri/src/updater/core.rs

Lines changed: 48 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -836,35 +836,35 @@ fn copy_files_and_run<R: Read + Seek>(
836836
// If it's an `exe` we expect an installer not a runtime.
837837
if found_path.extension() == Some(OsStr::new("exe")) {
838838
// we need to wrap the installer path in quotes for Start-Process
839-
let mut installer_arg = std::ffi::OsString::new();
840-
installer_arg.push("\"");
841-
installer_arg.push(&found_path);
842-
installer_arg.push("\"");
839+
let mut installer_path = std::ffi::OsString::new();
840+
installer_path.push("\"");
841+
installer_path.push(&found_path);
842+
installer_path.push("\"");
843+
844+
let installer_args = [
845+
config.tauri.updater.windows.install_mode.nsis_args(),
846+
config
847+
.tauri
848+
.updater
849+
.windows
850+
.installer_args
851+
.iter()
852+
.map(AsRef::as_ref)
853+
.collect::<Vec<_>>()
854+
.as_slice(),
855+
]
856+
.concat();
843857

844858
// Run the EXE
845-
Command::new(powershell_path)
859+
let mut cmd = Command::new(powershell_path);
860+
cmd
846861
.args(["-NoProfile", "-WindowStyle", "Hidden"])
847862
.args(["Start-Process"])
848-
.arg(installer_arg)
849-
.arg("-ArgumentList")
850-
.arg(
851-
[
852-
config.tauri.updater.windows.install_mode.nsis_args(),
853-
config
854-
.tauri
855-
.updater
856-
.windows
857-
.installer_args
858-
.iter()
859-
.map(AsRef::as_ref)
860-
.collect::<Vec<_>>()
861-
.as_slice(),
862-
]
863-
.concat()
864-
.join(", "),
865-
)
866-
.spawn()
867-
.expect("installer failed to start");
863+
.arg(installer_path);
864+
if !installer_args.is_empty() {
865+
cmd.arg("-ArgumentList").arg(installer_args.join(", "));
866+
}
867+
cmd.spawn().expect("installer failed to start");
868868

869869
exit(0);
870870
} else if found_path.extension() == Some(OsStr::new("msi")) {
@@ -913,21 +913,24 @@ fn copy_files_and_run<R: Read + Seek>(
913913
current_exe_arg.push(current_exe()?);
914914
current_exe_arg.push("\"");
915915

916-
let mut msi_path_arg = std::ffi::OsString::new();
917-
msi_path_arg.push("\"\"\"");
918-
msi_path_arg.push(&found_path);
919-
msi_path_arg.push("\"\"\"");
920-
921-
let mut msiexec_args = config
922-
.tauri
923-
.updater
924-
.windows
925-
.install_mode
926-
.msiexec_args()
927-
.iter()
928-
.map(|p| p.to_string())
929-
.collect::<Vec<String>>();
930-
msiexec_args.extend(config.tauri.updater.windows.installer_args.clone());
916+
let mut msi_path = std::ffi::OsString::new();
917+
msi_path.push("\"\"\"");
918+
msi_path.push(&found_path);
919+
msi_path.push("\"\"\"");
920+
921+
let installer_args = [
922+
config.tauri.updater.windows.install_mode.msiexec_args(),
923+
config
924+
.tauri
925+
.updater
926+
.windows
927+
.installer_args
928+
.iter()
929+
.map(AsRef::as_ref)
930+
.collect::<Vec<_>>()
931+
.as_slice(),
932+
]
933+
.concat();
931934

932935
// run the installer and relaunch the application
933936
let powershell_install_res = Command::new(powershell_path)
@@ -936,12 +939,12 @@ fn copy_files_and_run<R: Read + Seek>(
936939
"Start-Process",
937940
"-Wait",
938941
"-FilePath",
939-
"$env:SYSTEMROOT\\System32\\msiexec.exe",
942+
"$Env:SYSTEMROOT\\System32\\msiexec.exe",
940943
"-ArgumentList",
941944
])
942945
.arg("/i,")
943-
.arg(&msi_path_arg)
944-
.arg(format!(", {}, /promptrestart;", msiexec_args.join(", ")))
946+
.arg(&msi_path)
947+
.arg(format!(", {}, /promptrestart;", installer_args.join(", ")))
945948
.arg("Start-Process")
946949
.arg(current_exe_arg)
947950
.spawn();
@@ -954,8 +957,8 @@ fn copy_files_and_run<R: Read + Seek>(
954957
);
955958
let _ = Command::new(msiexec_path)
956959
.arg("/i")
957-
.arg(msi_path_arg)
958-
.args(msiexec_args)
960+
.arg(msi_path)
961+
.args(installer_args)
959962
.arg("/promptrestart")
960963
.spawn();
961964
}

0 commit comments

Comments
 (0)