Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(nsis): restart app after updating, closes #6955 #6987

Merged
merged 2 commits into from
May 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/nsis-install-mode-args.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'tauri-utils': 'patch'
---

Add `WindowsUpdateInstallMode::nsis_args`
6 changes: 6 additions & 0 deletions .changes/nsis-updater-restart.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'tauri': 'minor'
'cli.rs': 'minor'
---

Restart the app after the NSIS updater is finished.
4 changes: 2 additions & 2 deletions core/tauri-config-schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2808,14 +2808,14 @@
]
},
{
"description": "The quiet mode means there's no user interaction required. Requires admin privileges if the installer does (WiX).",
"description": "The quiet mode means there's no user interaction required. Requires admin privileges if the installer does.",
"type": "string",
"enum": [
"quiet"
]
},
{
"description": "Specifies unattended mode, which means the installation only shows a progress bar.",
"description": "Specifies unattended mode, which means the installation only shows a progress bar. **msi (Wix) Only**",
"type": "string",
"enum": [
"passive"
Expand Down
12 changes: 10 additions & 2 deletions core/tauri-utils/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2479,9 +2479,9 @@ pub enum WindowsUpdateInstallMode {
/// Specifies there's a basic UI during the installation process, including a final dialog box at the end.
BasicUi,
/// The quiet mode means there's no user interaction required.
/// Requires admin privileges if the installer does (WiX).
/// Requires admin privileges if the installer does.
Quiet,
/// Specifies unattended mode, which means the installation only shows a progress bar.
/// Specifies unattended mode, which means the installation only shows a progress bar. **msi (Wix) Only**
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 @@ -2496,6 +2496,14 @@ impl WindowsUpdateInstallMode {
Self::Passive => &["/passive"],
}
}

/// Returns the associated nsis arguments.
pub fn nsis_args(&self) -> &'static [&'static str] {
match self {
Self::Quiet => &["/S", "/R"],
_ => &[],
}
}
}

impl Display for WindowsUpdateInstallMode {
Expand Down
3 changes: 1 addition & 2 deletions core/tauri/src/updater/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ fn copy_files_and_run<R: Read + Seek>(
if crate::utils::config::WindowsUpdateInstallMode::Quiet
== config.tauri.updater.windows.install_mode
{
installer.arg("/S");
installer.args(config.tauri.updater.windows.install_mode.nsis_args());
}
installer.args(&config.tauri.updater.windows.installer_args);

Expand Down Expand Up @@ -802,7 +802,6 @@ fn copy_files_and_run<R: Read + Seek>(
.updater
.windows
.install_mode
.clone()
.msiexec_args()
.iter()
.map(|p| p.to_string())
Expand Down
11 changes: 11 additions & 0 deletions tooling/bundler/src/bundle/windows/templates/installer.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,17 @@ Section Install

SectionEnd

Var Restart
Function .onInstSuccess
; Check for `/R` flag only in silent installer because
; gui installer has a toggle for the user to restart the app
IfSilent 0 done
${GetOptions} $CMDLINE "/R" $Restart
IfErrors done 0 ; if errors were found then `/R` wasn't passed, so we skip restarting
Exec '"$INSTDIR\${MAINBINARYNAME}.exe"'
done:
FunctionEnd

Function un.onInit
!if "${INSTALLMODE}" == "both"
!insertmacro MULTIUSER_UNINIT
Expand Down
4 changes: 2 additions & 2 deletions tooling/cli/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2808,14 +2808,14 @@
]
},
{
"description": "The quiet mode means there's no user interaction required. Requires admin privileges if the installer does (WiX).",
"description": "The quiet mode means there's no user interaction required. Requires admin privileges if the installer does.",
"type": "string",
"enum": [
"quiet"
]
},
{
"description": "Specifies unattended mode, which means the installation only shows a progress bar.",
"description": "Specifies unattended mode, which means the installation only shows a progress bar. **msi (Wix) Only**",
"type": "string",
"enum": [
"passive"
Expand Down