Skip to content

Commit cd3846c

Browse files
authored
feat(nsis): restart app after updating, closes #6955 (#6987)
* feat(nsis): restart app after updating, closes #6955 * Apply suggestions from code review
1 parent fd3b5a1 commit cd3846c

File tree

7 files changed

+37
-8
lines changed

7 files changed

+37
-8
lines changed

.changes/nsis-install-mode-args.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'tauri-utils': 'patch'
3+
---
4+
5+
Add `WindowsUpdateInstallMode::nsis_args`

.changes/nsis-updater-restart.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'tauri': 'minor'
3+
'cli.rs': 'minor'
4+
---
5+
6+
Restart the app after the NSIS updater is finished.

core/tauri-config-schema/schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2808,14 +2808,14 @@
28082808
]
28092809
},
28102810
{
2811-
"description": "The quiet mode means there's no user interaction required. Requires admin privileges if the installer does (WiX).",
2811+
"description": "The quiet mode means there's no user interaction required. Requires admin privileges if the installer does.",
28122812
"type": "string",
28132813
"enum": [
28142814
"quiet"
28152815
]
28162816
},
28172817
{
2818-
"description": "Specifies unattended mode, which means the installation only shows a progress bar.",
2818+
"description": "Specifies unattended mode, which means the installation only shows a progress bar. **msi (Wix) Only**",
28192819
"type": "string",
28202820
"enum": [
28212821
"passive"

core/tauri-utils/src/config.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2479,9 +2479,9 @@ pub enum WindowsUpdateInstallMode {
24792479
/// Specifies there's a basic UI during the installation process, including a final dialog box at the end.
24802480
BasicUi,
24812481
/// The quiet mode means there's no user interaction required.
2482-
/// Requires admin privileges if the installer does (WiX).
2482+
/// Requires admin privileges if the installer does.
24832483
Quiet,
2484-
/// Specifies unattended mode, which means the installation only shows a progress bar.
2484+
/// Specifies unattended mode, which means the installation only shows a progress bar. **msi (Wix) Only**
24852485
Passive,
24862486
// to add more modes, we need to check if the updater relaunch makes sense
24872487
// i.e. for a full UI mode, the user can also mark the installer to start the app
@@ -2496,6 +2496,14 @@ impl WindowsUpdateInstallMode {
24962496
Self::Passive => &["/passive"],
24972497
}
24982498
}
2499+
2500+
/// Returns the associated nsis arguments.
2501+
pub fn nsis_args(&self) -> &'static [&'static str] {
2502+
match self {
2503+
Self::Quiet => &["/S", "/R"],
2504+
_ => &[],
2505+
}
2506+
}
24992507
}
25002508

25012509
impl Display for WindowsUpdateInstallMode {

core/tauri/src/updater/core.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ fn copy_files_and_run<R: Read + Seek>(
739739
if crate::utils::config::WindowsUpdateInstallMode::Quiet
740740
== config.tauri.updater.windows.install_mode
741741
{
742-
installer.arg("/S");
742+
installer.args(config.tauri.updater.windows.install_mode.nsis_args());
743743
}
744744
installer.args(&config.tauri.updater.windows.installer_args);
745745

@@ -802,7 +802,6 @@ fn copy_files_and_run<R: Read + Seek>(
802802
.updater
803803
.windows
804804
.install_mode
805-
.clone()
806805
.msiexec_args()
807806
.iter()
808807
.map(|p| p.to_string())

tooling/bundler/src/bundle/windows/templates/installer.nsi

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,17 @@ Section Install
472472

473473
SectionEnd
474474

475+
Var Restart
476+
Function .onInstSuccess
477+
; Check for `/R` flag only in silent installer because
478+
; gui installer has a toggle for the user to restart the app
479+
IfSilent 0 done
480+
${GetOptions} $CMDLINE "/R" $Restart
481+
IfErrors done 0 ; if errors were found then `/R` wasn't passed, so we skip restarting
482+
Exec '"$INSTDIR\${MAINBINARYNAME}.exe"'
483+
done:
484+
FunctionEnd
485+
475486
Function un.onInit
476487
!if "${INSTALLMODE}" == "both"
477488
!insertmacro MULTIUSER_UNINIT

tooling/cli/schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2808,14 +2808,14 @@
28082808
]
28092809
},
28102810
{
2811-
"description": "The quiet mode means there's no user interaction required. Requires admin privileges if the installer does (WiX).",
2811+
"description": "The quiet mode means there's no user interaction required. Requires admin privileges if the installer does.",
28122812
"type": "string",
28132813
"enum": [
28142814
"quiet"
28152815
]
28162816
},
28172817
{
2818-
"description": "Specifies unattended mode, which means the installation only shows a progress bar.",
2818+
"description": "Specifies unattended mode, which means the installation only shows a progress bar. **msi (Wix) Only**",
28192819
"type": "string",
28202820
"enum": [
28212821
"passive"

0 commit comments

Comments
 (0)