Skip to content

Commit

Permalink
feat(nsis): implement passive mode, closes #6955 (#6998)
Browse files Browse the repository at this point in the history
Co-authored-by: Lucas Nogueira <[email protected]>
  • Loading branch information
amrbashir and lucasfernog authored May 24, 2023
1 parent 60334f9 commit df89ccc
Show file tree
Hide file tree
Showing 11 changed files with 147 additions and 81 deletions.
5 changes: 5 additions & 0 deletions .changes/nsis-downgrades.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'tauri-bundler': 'patch'
---

Fix NSIS installer disabling `do not uninstall` button and silent installer aborting, if `allowDowngrades` was disabled even when we are not downgrading.
5 changes: 5 additions & 0 deletions .changes/nsis-passive-mode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'tauri': 'minor'
---

Support `passive` mode for NSIS updater.
5 changes: 5 additions & 0 deletions .changes/nsis-restart-flag.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'tauri-bundler': 'minor'
---

For NSIS, Add support for `/P` to install or uninstall in passive mode, `/R` to (re)start the app and `/NS` to disable creating shortcuts in `silent` and `passive` modes.
5 changes: 5 additions & 0 deletions .changes/nsis-silent-kill.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'tauri-bundler': 'minor'
---

NSIS `silent` and `passive` installer/updater will auto-kill the app if its running.
5 changes: 5 additions & 0 deletions .changes/nsis-silent-shortcuts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'tauri-bundler': 'patch'
---

Fix NSIS silent installer not creating Desktop and StartMenu shortcuts. Pass `/NS` to disable creating them.
2 changes: 1 addition & 1 deletion core/tauri-config-schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2822,7 +2822,7 @@
]
},
{
"description": "Specifies unattended mode, which means the installation only shows a progress bar. **msi (Wix) Only**",
"description": "Specifies unattended mode, which means the installation only shows a progress bar.",
"type": "string",
"enum": [
"passive"
Expand Down
3 changes: 2 additions & 1 deletion core/tauri-utils/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2466,7 +2466,7 @@ pub enum WindowsUpdateInstallMode {
/// The quiet mode means there's no user interaction required.
/// Requires admin privileges if the installer does.
Quiet,
/// Specifies unattended mode, which means the installation only shows a progress bar. **msi (Wix) Only**
/// Specifies unattended mode, which means the installation only shows a progress bar.
Passive,
// to add more modes, we need to check if the updater relaunch makes sense
// i.e. for a full UI mode, the user can also mark the installer to start the app
Expand All @@ -2485,6 +2485,7 @@ impl WindowsUpdateInstallMode {
/// Returns the associated nsis arguments.
pub fn nsis_args(&self) -> &'static [&'static str] {
match self {
Self::Passive => &["/P", "/R"],
Self::Quiet => &["/S", "/R"],
_ => &[],
}
Expand Down
14 changes: 5 additions & 9 deletions core/tauri/src/updater/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -735,15 +735,11 @@ fn copy_files_and_run<R: Read + Seek>(
// If it's an `exe` we expect an installer not a runtime.
if found_path.extension() == Some(OsStr::new("exe")) {
// Run the EXE
let mut installer = Command::new(found_path);
if crate::utils::config::WindowsUpdateInstallMode::Quiet
== config.tauri.updater.windows.install_mode
{
installer.args(config.tauri.updater.windows.install_mode.nsis_args());
}
installer.args(&config.tauri.updater.windows.installer_args);

installer.spawn().expect("installer failed to start");
Command::new(found_path)
.args(config.tauri.updater.windows.install_mode.nsis_args())
.args(&config.tauri.updater.windows.installer_args)
.spawn()
.expect("installer failed to start");

exit(0);
} else if found_path.extension() == Some(OsStr::new("msi")) {
Expand Down
Loading

0 comments on commit df89ccc

Please sign in to comment.