Skip to content

Commit c94e132

Browse files
amrbashirFabianLarslucasfernog
authored
feat(bundler): add nsis, closes #4450, closes #2319 (#4674)
Co-authored-by: Fabian-Lars <fabianlars@fabianlars.de> Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
1 parent 4892637 commit c94e132

File tree

22 files changed

+1718
-286
lines changed

22 files changed

+1718
-286
lines changed

.changes/nsis.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"tauri-bundler": minor
3+
"tauri-utils": minor
4+
"cli.rs": minor
5+
"cli.js": minor
6+
---
7+
8+
Add `nsis` bundle target

core/config-schema/schema.json

Lines changed: 107 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@
146146
"allowDowngrades": true,
147147
"certificateThumbprint": null,
148148
"digestAlgorithm": null,
149+
"nsis": null,
149150
"timestampUrl": null,
150151
"tsp": false,
151152
"webviewFixedRuntimePath": null,
@@ -169,7 +170,8 @@
169170
"dialog": true,
170171
"pubkey": "",
171172
"windows": {
172-
"installMode": "passive"
173+
"installMode": "passive",
174+
"installerArgs": []
173175
}
174176
},
175177
"windows": []
@@ -282,6 +284,7 @@
282284
"allowDowngrades": true,
283285
"certificateThumbprint": null,
284286
"digestAlgorithm": null,
287+
"nsis": null,
285288
"timestampUrl": null,
286289
"tsp": false,
287290
"webviewFixedRuntimePath": null,
@@ -427,7 +430,8 @@
427430
"dialog": true,
428431
"pubkey": "",
429432
"windows": {
430-
"installMode": "passive"
433+
"installMode": "passive",
434+
"installerArgs": []
431435
}
432436
},
433437
"allOf": [
@@ -1018,7 +1022,7 @@
10181022
"type": "boolean"
10191023
},
10201024
"targets": {
1021-
"description": "The bundle targets, currently supports [\"deb\", \"appimage\", \"msi\", \"app\", \"dmg\", \"updater\"] or \"all\".",
1025+
"description": "The bundle targets, currently supports [\"deb\", \"appimage\", \"nsis\", \"msi\", \"app\", \"dmg\", \"updater\"] or \"all\".",
10221026
"default": "all",
10231027
"allOf": [
10241028
{
@@ -1132,6 +1136,7 @@
11321136
"allowDowngrades": true,
11331137
"certificateThumbprint": null,
11341138
"digestAlgorithm": null,
1139+
"nsis": null,
11351140
"timestampUrl": null,
11361141
"tsp": false,
11371142
"webviewFixedRuntimePath": null,
@@ -1200,6 +1205,13 @@
12001205
"msi"
12011206
]
12021207
},
1208+
{
1209+
"description": "The NSIS bundle (.exe).",
1210+
"type": "string",
1211+
"enum": [
1212+
"nsis"
1213+
]
1214+
},
12031215
{
12041216
"description": "The macOS application bundle (.app).",
12051217
"type": "string",
@@ -1384,6 +1396,17 @@
13841396
"type": "null"
13851397
}
13861398
]
1399+
},
1400+
"nsis": {
1401+
"description": "Configuration for the installer generated with NSIS.",
1402+
"anyOf": [
1403+
{
1404+
"$ref": "#/definitions/NsisConfig"
1405+
},
1406+
{
1407+
"type": "null"
1408+
}
1409+
]
13871410
}
13881411
},
13891412
"additionalProperties": false
@@ -1632,6 +1655,76 @@
16321655
},
16331656
"additionalProperties": false
16341657
},
1658+
"NsisConfig": {
1659+
"description": "Configuration for the Installer bundle using NSIS.",
1660+
"type": "object",
1661+
"properties": {
1662+
"license": {
1663+
"description": "The path to the license file to render on the installer.",
1664+
"type": [
1665+
"string",
1666+
"null"
1667+
]
1668+
},
1669+
"headerImage": {
1670+
"description": "The path to a bitmap file to display on the header of installers pages.\n\nThe recommended dimensions are 150px x 57px.",
1671+
"type": [
1672+
"string",
1673+
"null"
1674+
]
1675+
},
1676+
"sidebarImage": {
1677+
"description": "The path to a bitmap file for the Welcome page and the Finish page.\n\nThe recommended dimensions are 164px x 314px.",
1678+
"type": [
1679+
"string",
1680+
"null"
1681+
]
1682+
},
1683+
"installerIcon": {
1684+
"description": "The path to an icon file used as the installer icon.",
1685+
"type": [
1686+
"string",
1687+
"null"
1688+
]
1689+
},
1690+
"installMode": {
1691+
"description": "Whether the installation will be for all users or just the current user.",
1692+
"default": "currentUser",
1693+
"allOf": [
1694+
{
1695+
"$ref": "#/definitions/NSISInstallerMode"
1696+
}
1697+
]
1698+
}
1699+
},
1700+
"additionalProperties": false
1701+
},
1702+
"NSISInstallerMode": {
1703+
"description": "Install Modes for the NSIS installer.",
1704+
"oneOf": [
1705+
{
1706+
"description": "Default mode for the installer.\n\nInstall the app by default in a directory that doesn't require Administrator access.\n\nInstaller metadata will be saved under the `HKCU` registry path.",
1707+
"type": "string",
1708+
"enum": [
1709+
"currentUser"
1710+
]
1711+
},
1712+
{
1713+
"description": "Install the app by default in the `Program Files` folder directory requires Administrator access for the installation.\n\nInstaller metadata will be saved under the `HKLM` registry path.",
1714+
"type": "string",
1715+
"enum": [
1716+
"perMachine"
1717+
]
1718+
},
1719+
{
1720+
"description": "Combines both modes and allows the user to choose at install time whether to install for the current user or per machine. Note that this mode will require Administrator access even if the user wants to install it for the current user only.\n\nInstaller metadata will be saved under the `HKLM` or `HKCU` registry path based on the user's choice.",
1721+
"type": "string",
1722+
"enum": [
1723+
"both"
1724+
]
1725+
}
1726+
]
1727+
},
16351728
"AllowlistConfig": {
16361729
"description": "Allowlist configuration.",
16371730
"type": "object",
@@ -2579,7 +2672,8 @@
25792672
"windows": {
25802673
"description": "The Windows configuration for the updater.",
25812674
"default": {
2582-
"installMode": "passive"
2675+
"installMode": "passive",
2676+
"installerArgs": []
25832677
},
25842678
"allOf": [
25852679
{
@@ -2599,6 +2693,14 @@
25992693
"description": "The updater configuration for Windows.",
26002694
"type": "object",
26012695
"properties": {
2696+
"installerArgs": {
2697+
"description": "Additional arguments given to the NSIS or WiX installer.",
2698+
"default": [],
2699+
"type": "array",
2700+
"items": {
2701+
"type": "string"
2702+
}
2703+
},
26022704
"installMode": {
26032705
"description": "The installation mode for the update on Windows. Defaults to `passive`.",
26042706
"default": "passive",
@@ -2622,7 +2724,7 @@
26222724
]
26232725
},
26242726
{
2625-
"description": "The quiet mode means there's no user interaction required. Requires admin privileges if the installer does.",
2727+
"description": "The quiet mode means there's no user interaction required. Requires admin privileges if the installer does (WiX).",
26262728
"type": "string",
26272729
"enum": [
26282730
"quiet"

core/tauri-utils/src/config.rs

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ pub enum BundleType {
7878
AppImage,
7979
/// The Microsoft Installer bundle (.msi).
8080
Msi,
81+
/// The NSIS bundle (.exe).
82+
Nsis,
8183
/// The macOS application bundle (.app).
8284
App,
8385
/// The Apple Disk Image bundle (.dmg).
@@ -95,6 +97,7 @@ impl Display for BundleType {
9597
Self::Deb => "deb",
9698
Self::AppImage => "appimage",
9799
Self::Msi => "msi",
100+
Self::Nsis => "nsis",
98101
Self::App => "app",
99102
Self::Dmg => "dmg",
100103
Self::Updater => "updater",
@@ -122,6 +125,7 @@ impl<'de> Deserialize<'de> for BundleType {
122125
"deb" => Ok(Self::Deb),
123126
"appimage" => Ok(Self::AppImage),
124127
"msi" => Ok(Self::Msi),
128+
"nsis" => Ok(Self::Nsis),
125129
"app" => Ok(Self::App),
126130
"dmg" => Ok(Self::Dmg),
127131
"updater" => Ok(Self::Updater),
@@ -416,6 +420,58 @@ pub struct WixConfig {
416420
pub dialog_image_path: Option<PathBuf>,
417421
}
418422

423+
/// Configuration for the Installer bundle using NSIS.
424+
#[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)]
425+
#[cfg_attr(feature = "schema", derive(JsonSchema))]
426+
#[serde(rename_all = "camelCase", deny_unknown_fields)]
427+
pub struct NsisConfig {
428+
/// The path to the license file to render on the installer.
429+
pub license: Option<PathBuf>,
430+
/// The path to a bitmap file to display on the header of installers pages.
431+
///
432+
/// The recommended dimensions are 150px x 57px.
433+
pub header_image: Option<PathBuf>,
434+
/// The path to a bitmap file for the Welcome page and the Finish page.
435+
///
436+
/// The recommended dimensions are 164px x 314px.
437+
pub sidebar_image: Option<PathBuf>,
438+
/// The path to an icon file used as the installer icon.
439+
pub installer_icon: Option<PathBuf>,
440+
/// Whether the installation will be for all users or just the current user.
441+
#[serde(default)]
442+
pub install_mode: NSISInstallerMode,
443+
}
444+
445+
/// Install Modes for the NSIS installer.
446+
#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize)]
447+
#[serde(rename_all = "camelCase", deny_unknown_fields)]
448+
#[cfg_attr(feature = "schema", derive(JsonSchema))]
449+
pub enum NSISInstallerMode {
450+
/// Default mode for the installer.
451+
///
452+
/// Install the app by default in a directory that doesn't require Administrator access.
453+
///
454+
/// Installer metadata will be saved under the `HKCU` registry path.
455+
CurrentUser,
456+
/// Install the app by default in the `Program Files` folder directory requires Administrator
457+
/// access for the installation.
458+
///
459+
/// Installer metadata will be saved under the `HKLM` registry path.
460+
PerMachine,
461+
/// Combines both modes and allows the user to choose at install time
462+
/// whether to install for the current user or per machine. Note that this mode
463+
/// will require Administrator access even if the user wants to install it for the current user only.
464+
///
465+
/// Installer metadata will be saved under the `HKLM` or `HKCU` registry path based on the user's choice.
466+
Both,
467+
}
468+
469+
impl Default for NSISInstallerMode {
470+
fn default() -> Self {
471+
Self::CurrentUser
472+
}
473+
}
474+
419475
/// Install modes for the Webview2 runtime.
420476
/// Note that for the updater bundle [`Self::DownloadBootstrapper`] is used.
421477
///
@@ -512,6 +568,8 @@ pub struct WindowsConfig {
512568
pub allow_downgrades: bool,
513569
/// Configuration for the MSI generated with WiX.
514570
pub wix: Option<WixConfig>,
571+
/// Configuration for the installer generated with NSIS.
572+
pub nsis: Option<NsisConfig>,
515573
}
516574

517575
impl Default for WindowsConfig {
@@ -525,6 +583,7 @@ impl Default for WindowsConfig {
525583
webview_fixed_runtime_path: None,
526584
allow_downgrades: default_allow_downgrades(),
527585
wix: None,
586+
nsis: None,
528587
}
529588
}
530589
}
@@ -542,7 +601,7 @@ pub struct BundleConfig {
542601
/// Whether Tauri should bundle your application or just output the executable.
543602
#[serde(default)]
544603
pub active: bool,
545-
/// The bundle targets, currently supports ["deb", "appimage", "msi", "app", "dmg", "updater"] or "all".
604+
/// The bundle targets, currently supports ["deb", "appimage", "nsis", "msi", "app", "dmg", "updater"] or "all".
546605
#[serde(default)]
547606
pub targets: BundleTarget,
548607
/// The application identifier in reverse domain name notation (e.g. `com.tauri.example`).
@@ -2306,7 +2365,7 @@ pub enum WindowsUpdateInstallMode {
23062365
/// Specifies there's a basic UI during the installation process, including a final dialog box at the end.
23072366
BasicUi,
23082367
/// The quiet mode means there's no user interaction required.
2309-
/// Requires admin privileges if the installer does.
2368+
/// Requires admin privileges if the installer does (WiX).
23102369
Quiet,
23112370
/// Specifies unattended mode, which means the installation only shows a progress bar.
23122371
Passive,
@@ -2377,6 +2436,9 @@ impl<'de> Deserialize<'de> for WindowsUpdateInstallMode {
23772436
#[cfg_attr(feature = "schema", derive(JsonSchema))]
23782437
#[serde(rename_all = "camelCase", deny_unknown_fields)]
23792438
pub struct UpdaterWindowsConfig {
2439+
/// Additional arguments given to the NSIS or WiX installer.
2440+
#[serde(default, alias = "installer-args")]
2441+
pub installer_args: Vec<String>,
23802442
/// The installation mode for the update on Windows. Defaults to `passive`.
23812443
#[serde(default, alias = "install-mode")]
23822444
pub install_mode: WindowsUpdateInstallMode,
@@ -3355,7 +3417,8 @@ mod build {
33553417
impl ToTokens for UpdaterWindowsConfig {
33563418
fn to_tokens(&self, tokens: &mut TokenStream) {
33573419
let install_mode = &self.install_mode;
3358-
literal_struct!(tokens, UpdaterWindowsConfig, install_mode);
3420+
let installer_args = vec_lit(&self.installer_args, str_lit);
3421+
literal_struct!(tokens, UpdaterWindowsConfig, install_mode, installer_args);
33593422
}
33603423
}
33613424

0 commit comments

Comments
 (0)