Skip to content

Commit 926a57b

Browse files
feat(windows): NSIS uninstaller icon and header image support (#15201)
* feat: NSIS uninstaller support. * chore: fix typo and update schema. * fix: comments and alias. * fix: add pages for uninst sidebar. * chore: fix typo in comments of fields. * fix: group HEADERIMAGE. * fix: remove welcome/finish of uninstaller. * fix: remove uninstaller_sidebar_image. * Update crates/tauri-utils/src/config.rs Co-authored-by: Tony <68118705+Legend-Master@users.noreply.github.com> * chore: revert comments. * chore: update schema. * Update crates/tauri-utils/src/config.rs Co-authored-by: Tony <68118705+Legend-Master@users.noreply.github.com> * Update crates/tauri-utils/src/config.rs Co-authored-by: Tony <68118705+Legend-Master@users.noreply.github.com> * fix: typo of installer_icon. * chore: add change file. * fix: typo. * chore: update config.json. * Update .changes/feat-uninstaller-icon-image.md Co-authored-by: Tony <68118705+Legend-Master@users.noreply.github.com> * fix: revert alias. * chore: update comments in settings.rs. * chore: update comments. * fix: installer.nsi * fix: installer.nsi --------- Co-authored-by: Tony <68118705+Legend-Master@users.noreply.github.com>
1 parent 074299c commit 926a57b

8 files changed

Lines changed: 94 additions & 2 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
"tauri-bundler": minor:feat
3+
"tauri-cli": minor:feat
4+
"@tauri-apps/cli": minor:feat
5+
"tauri-utils": minor:feat
6+
---
7+
8+
Added uninstaller icon and uninstaller header image support for NSIS installer.
9+
10+
Notes:
11+
12+
- For `tauri-bundler` lib users, the `NsisSettings` now has 2 new fields `uninstaller_icon` and `uninstaller_header_image` which can be a breaking change
13+
- When bundling with NSIS, users can add `uninstallerIcon` and `uninstallerHeaderImage` under `bundle > windows > nsis` to configure them.

crates/tauri-bundler/src/bundle/settings.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,13 @@ pub struct NsisSettings {
470470
pub sidebar_image: Option<PathBuf>,
471471
/// The path to an icon file used as the installer icon.
472472
pub installer_icon: Option<PathBuf>,
473+
/// The path to an icon file used as the uninstaller icon.
474+
pub uninstaller_icon: Option<PathBuf>,
475+
/// The path to a bitmap file to display on the header of uninstallers pages.
476+
/// Defaults to [`Self::header_image`]. If this is set but [`Self::header_image`] is not, a default image from NSIS will be applied to `header_image`
477+
///
478+
/// The recommended dimensions are 150px x 57px.
479+
pub uninstaller_header_image: Option<PathBuf>,
473480
/// Whether the installation will be for all users or just the current user.
474481
pub install_mode: NSISInstallerMode,
475482
/// A list of installer languages.

crates/tauri-bundler/src/bundle/windows/nsis/installer.nsi

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ ${StrLoc}
4141
!define INSTALLERICON "{{installer_icon}}"
4242
!define SIDEBARIMAGE "{{sidebar_image}}"
4343
!define HEADERIMAGE "{{header_image}}"
44+
!define UNINSTALLERICON "{{uninstaller_icon}}"
45+
!define UNINSTALLERHEADERIMAGE "{{uninstaller_header_image}}"
4446
!define MAINBINARYNAME "{{main_binary_name}}"
4547
!define MAINBINARYSRCPATH "{{main_binary_path}}"
4648
!define BUNDLEID "{{bundle_id}}"
@@ -129,10 +131,26 @@ VIAddVersionKey "ProductVersion" "${VERSION}"
129131
!define MUI_WELCOMEFINISHPAGE_BITMAP "${SIDEBARIMAGE}"
130132
!endif
131133

132-
; Installer header image
134+
; Enable header images for installer and uninstaller pages when either image is configured.
133135
!if "${HEADERIMAGE}" != ""
134136
!define MUI_HEADERIMAGE
135-
!define MUI_HEADERIMAGE_BITMAP "${HEADERIMAGE}"
137+
!else if "${UNINSTALLERHEADERIMAGE}" != ""
138+
!define MUI_HEADERIMAGE
139+
!endif
140+
141+
; Installer header image
142+
!if "${HEADERIMAGE}" != ""
143+
!define MUI_HEADERIMAGE_BITMAP "${HEADERIMAGE}"
144+
!endif
145+
146+
; Uninstaller header image
147+
!if "${UNINSTALLERHEADERIMAGE}" != ""
148+
!define MUI_HEADERIMAGE_UNBITMAP "${UNINSTALLERHEADERIMAGE}"
149+
!endif
150+
151+
; Uninstaller icon
152+
!if "${UNINSTALLERICON}" != ""
153+
!define MUI_UNICON "${UNINSTALLERICON}"
136154
!endif
137155

138156
; Define registry key to store installer language

crates/tauri-bundler/src/bundle/windows/nsis/mod.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,20 @@ fn build_nsis_app_installer(
354354
);
355355
}
356356

357+
if let Some(uninstaller_icon) = &nsis.uninstaller_icon {
358+
data.insert(
359+
"uninstaller_icon",
360+
to_json(dunce::canonicalize(uninstaller_icon)?),
361+
);
362+
}
363+
364+
if let Some(uninstaller_header_image) = &nsis.uninstaller_header_image {
365+
data.insert(
366+
"uninstaller_header_image",
367+
to_json(dunce::canonicalize(uninstaller_header_image)?),
368+
);
369+
}
370+
357371
if let Some(installer_hooks) = &nsis.installer_hooks {
358372
let installer_hooks = dunce::canonicalize(installer_hooks)?;
359373
data.insert("installer_hooks", to_json(installer_hooks));

crates/tauri-cli/config.schema.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2996,6 +2996,20 @@
29962996
"null"
29972997
]
29982998
},
2999+
"uninstallerIcon": {
3000+
"description": "The path to an icon file used as the uninstaller icon.",
3001+
"type": [
3002+
"string",
3003+
"null"
3004+
]
3005+
},
3006+
"uninstallerHeaderImage": {
3007+
"description": "The path to a bitmap file to display on the header of uninstallers pages.\n Defaults to [`Self::header_image`]. If this is set but [`Self::header_image`] is not, a default image from NSIS will be applied to `header_image`\n\n The recommended dimensions are 150px x 57px.",
3008+
"type": [
3009+
"string",
3010+
"null"
3011+
]
3012+
},
29993013
"installMode": {
30003014
"description": "Whether the installation will be for all users or just the current user.",
30013015
"default": "currentUser",

crates/tauri-cli/src/helpers/config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ pub fn nsis_settings(config: NsisConfig) -> tauri_bundler::NsisSettings {
110110
header_image: config.header_image,
111111
sidebar_image: config.sidebar_image,
112112
installer_icon: config.installer_icon,
113+
uninstaller_icon: config.uninstaller_icon,
114+
uninstaller_header_image: config.uninstaller_header_image,
113115
install_mode: config.install_mode,
114116
languages: config.languages,
115117
custom_language_files: config.custom_language_files,

crates/tauri-schema-generator/schemas/config.schema.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2996,6 +2996,20 @@
29962996
"null"
29972997
]
29982998
},
2999+
"uninstallerIcon": {
3000+
"description": "The path to an icon file used as the uninstaller icon.",
3001+
"type": [
3002+
"string",
3003+
"null"
3004+
]
3005+
},
3006+
"uninstallerHeaderImage": {
3007+
"description": "The path to a bitmap file to display on the header of uninstallers pages.\n Defaults to [`Self::header_image`]. If this is set but [`Self::header_image`] is not, a default image from NSIS will be applied to `header_image`\n\n The recommended dimensions are 150px x 57px.",
3008+
"type": [
3009+
"string",
3010+
"null"
3011+
]
3012+
},
29993013
"installMode": {
30003014
"description": "Whether the installation will be for all users or just the current user.",
30013015
"default": "currentUser",

crates/tauri-utils/src/config.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,9 +857,19 @@ pub struct NsisConfig {
857857
/// The recommended dimensions are 164px x 314px.
858858
#[serde(alias = "sidebar-image")]
859859
pub sidebar_image: Option<PathBuf>,
860+
// TODO: Change the alias to installer-icon in v3
860861
/// The path to an icon file used as the installer icon.
861862
#[serde(alias = "install-icon")]
862863
pub installer_icon: Option<PathBuf>,
864+
/// The path to an icon file used as the uninstaller icon.
865+
#[serde(alias = "uninstaller-icon")]
866+
pub uninstaller_icon: Option<PathBuf>,
867+
/// The path to a bitmap file to display on the header of uninstallers pages.
868+
/// Defaults to [`Self::header_image`]. If this is set but [`Self::header_image`] is not, a default image from NSIS will be applied to `header_image`
869+
///
870+
/// The recommended dimensions are 150px x 57px.
871+
#[serde(alias = "uninstaller-header-image")]
872+
pub uninstaller_header_image: Option<PathBuf>,
863873
/// Whether the installation will be for all users or just the current user.
864874
#[serde(default, alias = "install-mode")]
865875
pub install_mode: NSISInstallerMode,

0 commit comments

Comments
 (0)