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(bundler): add nsis, closes #4450, closes #2319 #4674

Merged
merged 50 commits into from Jan 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
5dc506c
feat(bundler): add `nsis`, closes #4450, closes #2319
amrbashir Jul 14, 2022
221cbc9
remove invalid doc comment
amrbashir Jul 15, 2022
6c1b1c6
look for webview2 x64 per machine installation
amrbashir Jul 15, 2022
ba83871
remove unnecessary pub
amrbashir Jul 15, 2022
77d893c
bundle resources
amrbashir Jul 15, 2022
ed6fe40
bundle externalBinaries
amrbashir Jul 15, 2022
2404f04
fix launch after install option
amrbashir Jul 15, 2022
f6f2a18
set AppUserModelID
amrbashir Jul 15, 2022
e5b72f7
set AppUserModelID for desktop shortcut too
amrbashir Jul 15, 2022
7d9f88e
add `allowDowngrades`, x32, lzma compression and reinstall page
amrbashir Jul 16, 2022
ab4e3c6
fix `allowDowngrades` and disable moving on without uninstalling first
amrbashir Jul 16, 2022
bdb7d96
abort silent installer if allowdowngrades is disabled
amrbashir Jul 17, 2022
8fba86a
webview2 install modes
amrbashir Jul 17, 2022
a4df69d
Prompt to kill if app is running
amrbashir Jul 18, 2022
7915944
fix NSIS warning
amrbashir Jul 18, 2022
2662ac6
updater
amrbashir Jul 18, 2022
d0b7250
remove a stray dbg!
amrbashir Jul 18, 2022
397c070
changefile
amrbashir Jul 18, 2022
d97e380
Merge branch 'dev' into nsis
amrbashir Jul 18, 2022
b8825b7
adjust bump to minor
amrbashir Jul 20, 2022
a5def17
Merge branch 'dev' into nsis
amrbashir Nov 1, 2022
f6ac3fd
fix APR display icon path
amrbashir Nov 1, 2022
3e371ed
Merge branch 'dev' into nsis
amrbashir Dec 8, 2022
e9904a7
fmt
amrbashir Dec 8, 2022
8f3c939
fix `!define` call
amrbashir Dec 8, 2022
bfbe0e7
fix bundling updater for multiple bundle targets
amrbashir Dec 8, 2022
cf145be
remove console window from api example on Windows
amrbashir Dec 8, 2022
ce0dea5
strip unc on windows only
amrbashir Dec 8, 2022
9413ee6
fix cli build on unix
amrbashir Dec 8, 2022
6279fea
download NSIS plugins from `tauri-apps/binary-releases`
amrbashir Dec 8, 2022
e36610f
fmt docs [skip ci]
lucasfernog Dec 14, 2022
e57a2b4
use constants [skip ci]
lucasfernog Dec 14, 2022
3c352b1
add HashAlgorithm enum [skip ci]
lucasfernog Dec 14, 2022
f5aaed7
add missing license header [skip ci]
lucasfernog Dec 14, 2022
9d10c0f
fix consts [skip ci]
lucasfernog Dec 15, 2022
4b2cc74
silent updater install
lucasfernog Dec 15, 2022
92cc7dc
installerargs option for updater
lucasfernog Dec 15, 2022
5df4876
add updater test
lucasfernog Dec 15, 2022
04391bd
optimize test
lucasfernog Dec 15, 2022
3eb73d1
fix wix test [skip ci]
lucasfernog Dec 15, 2022
6d09c29
Allow `major.minor.patch-pre` in NSIS
amrbashir Dec 16, 2022
91c20bc
Merge branch 'dev' into nsis
amrbashir Dec 16, 2022
70b06b6
switch to `NSIS-SemverCompare` plugin
amrbashir Dec 21, 2022
a8cfd7d
add support for both modes
amrbashir Dec 21, 2022
38a60fe
hide `installmode` file and make it readonly
amrbashir Dec 22, 2022
50ba0e3
Update core/tauri-utils/src/config.rs
amrbashir Dec 22, 2022
e36f74a
update schema.json
amrbashir Dec 22, 2022
51dcd14
use the new rust veresion of `nsis-semvercompare`
amrbashir Jan 2, 2023
b678c97
insert `install_mode` even if the `nsis` object is not defined in tau…
amrbashir Jan 2, 2023
d1179c7
delete only the files we install, no recursive
amrbashir Jan 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changes/nsis.md
@@ -0,0 +1,8 @@
---
"tauri-bundler": minor
"tauri-utils": minor
"cli.rs": minor
"cli.js": minor
---

Add `nsis` bundle target
112 changes: 107 additions & 5 deletions core/config-schema/schema.json
Expand Up @@ -146,6 +146,7 @@
"allowDowngrades": true,
"certificateThumbprint": null,
"digestAlgorithm": null,
"nsis": null,
"timestampUrl": null,
"tsp": false,
"webviewFixedRuntimePath": null,
Expand All @@ -169,7 +170,8 @@
"dialog": true,
"pubkey": "",
"windows": {
"installMode": "passive"
"installMode": "passive",
"installerArgs": []
}
},
"windows": []
Expand Down Expand Up @@ -282,6 +284,7 @@
"allowDowngrades": true,
"certificateThumbprint": null,
"digestAlgorithm": null,
"nsis": null,
"timestampUrl": null,
"tsp": false,
"webviewFixedRuntimePath": null,
Expand Down Expand Up @@ -427,7 +430,8 @@
"dialog": true,
"pubkey": "",
"windows": {
"installMode": "passive"
"installMode": "passive",
"installerArgs": []
}
},
"allOf": [
Expand Down Expand Up @@ -1018,7 +1022,7 @@
"type": "boolean"
},
"targets": {
"description": "The bundle targets, currently supports [\"deb\", \"appimage\", \"msi\", \"app\", \"dmg\", \"updater\"] or \"all\".",
"description": "The bundle targets, currently supports [\"deb\", \"appimage\", \"nsis\", \"msi\", \"app\", \"dmg\", \"updater\"] or \"all\".",
"default": "all",
"allOf": [
{
Expand Down Expand Up @@ -1132,6 +1136,7 @@
"allowDowngrades": true,
"certificateThumbprint": null,
"digestAlgorithm": null,
"nsis": null,
"timestampUrl": null,
"tsp": false,
"webviewFixedRuntimePath": null,
Expand Down Expand Up @@ -1200,6 +1205,13 @@
"msi"
]
},
{
"description": "The NSIS bundle (.exe).",
"type": "string",
"enum": [
"nsis"
]
},
{
"description": "The macOS application bundle (.app).",
"type": "string",
Expand Down Expand Up @@ -1384,6 +1396,17 @@
"type": "null"
}
]
},
"nsis": {
"description": "Configuration for the installer generated with NSIS.",
"anyOf": [
{
"$ref": "#/definitions/NsisConfig"
},
{
"type": "null"
}
]
}
},
"additionalProperties": false
Expand Down Expand Up @@ -1632,6 +1655,76 @@
},
"additionalProperties": false
},
"NsisConfig": {
"description": "Configuration for the Installer bundle using NSIS.",
"type": "object",
"properties": {
"license": {
"description": "The path to the license file to render on the installer.",
"type": [
"string",
"null"
]
},
"headerImage": {
"description": "The path to a bitmap file to display on the header of installers pages.\n\nThe recommended dimensions are 150px x 57px.",
"type": [
"string",
"null"
]
},
"sidebarImage": {
"description": "The path to a bitmap file for the Welcome page and the Finish page.\n\nThe recommended dimensions are 164px x 314px.",
"type": [
"string",
"null"
]
},
"installerIcon": {
"description": "The path to an icon file used as the installer icon.",
"type": [
"string",
"null"
]
},
"installMode": {
"description": "Whether the installation will be for all users or just the current user.",
"default": "currentUser",
"allOf": [
{
"$ref": "#/definitions/NSISInstallerMode"
}
]
}
},
"additionalProperties": false
},
"NSISInstallerMode": {
"description": "Install Modes for the NSIS installer.",
"oneOf": [
{
"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.",
"type": "string",
"enum": [
"currentUser"
]
},
{
"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.",
"type": "string",
"enum": [
"perMachine"
]
},
{
"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.",
"type": "string",
"enum": [
"both"
]
}
]
},
"AllowlistConfig": {
"description": "Allowlist configuration.",
"type": "object",
Expand Down Expand Up @@ -2579,7 +2672,8 @@
"windows": {
"description": "The Windows configuration for the updater.",
"default": {
"installMode": "passive"
"installMode": "passive",
"installerArgs": []
},
"allOf": [
{
Expand All @@ -2599,6 +2693,14 @@
"description": "The updater configuration for Windows.",
"type": "object",
"properties": {
"installerArgs": {
"description": "Additional arguments given to the NSIS or WiX installer.",
"default": [],
"type": "array",
"items": {
"type": "string"
}
},
"installMode": {
"description": "The installation mode for the update on Windows. Defaults to `passive`.",
"default": "passive",
Expand All @@ -2622,7 +2724,7 @@
]
},
{
"description": "The quiet mode means there's no user interaction required. Requires admin privileges if the installer does.",
"description": "The quiet mode means there's no user interaction required. Requires admin privileges if the installer does (WiX).",
"type": "string",
"enum": [
"quiet"
Expand Down
69 changes: 66 additions & 3 deletions core/tauri-utils/src/config.rs
Expand Up @@ -78,6 +78,8 @@ pub enum BundleType {
AppImage,
/// The Microsoft Installer bundle (.msi).
Msi,
/// The NSIS bundle (.exe).
Nsis,
/// The macOS application bundle (.app).
App,
/// The Apple Disk Image bundle (.dmg).
Expand All @@ -95,6 +97,7 @@ impl Display for BundleType {
Self::Deb => "deb",
Self::AppImage => "appimage",
Self::Msi => "msi",
Self::Nsis => "nsis",
Self::App => "app",
Self::Dmg => "dmg",
Self::Updater => "updater",
Expand Down Expand Up @@ -122,6 +125,7 @@ impl<'de> Deserialize<'de> for BundleType {
"deb" => Ok(Self::Deb),
"appimage" => Ok(Self::AppImage),
"msi" => Ok(Self::Msi),
"nsis" => Ok(Self::Nsis),
"app" => Ok(Self::App),
"dmg" => Ok(Self::Dmg),
"updater" => Ok(Self::Updater),
Expand Down Expand Up @@ -416,6 +420,58 @@ pub struct WixConfig {
pub dialog_image_path: Option<PathBuf>,
}

/// Configuration for the Installer bundle using NSIS.
#[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)]
#[cfg_attr(feature = "schema", derive(JsonSchema))]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct NsisConfig {
/// The path to the license file to render on the installer.
pub license: Option<PathBuf>,
/// The path to a bitmap file to display on the header of installers pages.
///
/// The recommended dimensions are 150px x 57px.
pub header_image: Option<PathBuf>,
/// The path to a bitmap file for the Welcome page and the Finish page.
///
/// The recommended dimensions are 164px x 314px.
pub sidebar_image: Option<PathBuf>,
/// The path to an icon file used as the installer icon.
pub installer_icon: Option<PathBuf>,
/// Whether the installation will be for all users or just the current user.
#[serde(default)]
pub install_mode: NSISInstallerMode,
}

/// Install Modes for the NSIS installer.
#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
#[cfg_attr(feature = "schema", derive(JsonSchema))]
pub enum NSISInstallerMode {
/// Default mode for the installer.
///
/// Install the app by default in a directory that doesn't require Administrator access.
///
/// Installer metadata will be saved under the `HKCU` registry path.
CurrentUser,
/// Install the app by default in the `Program Files` folder directory requires Administrator
/// access for the installation.
///
/// Installer metadata will be saved under the `HKLM` registry path.
PerMachine,
/// 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.
///
/// Installer metadata will be saved under the `HKLM` or `HKCU` registry path based on the user's choice.
Both,
}

impl Default for NSISInstallerMode {
fn default() -> Self {
Self::CurrentUser
}
}

/// Install modes for the Webview2 runtime.
/// Note that for the updater bundle [`Self::DownloadBootstrapper`] is used.
///
Expand Down Expand Up @@ -512,6 +568,8 @@ pub struct WindowsConfig {
pub allow_downgrades: bool,
/// Configuration for the MSI generated with WiX.
pub wix: Option<WixConfig>,
/// Configuration for the installer generated with NSIS.
pub nsis: Option<NsisConfig>,
}

impl Default for WindowsConfig {
Expand All @@ -525,6 +583,7 @@ impl Default for WindowsConfig {
webview_fixed_runtime_path: None,
allow_downgrades: default_allow_downgrades(),
wix: None,
nsis: None,
}
}
}
Expand All @@ -542,7 +601,7 @@ pub struct BundleConfig {
/// Whether Tauri should bundle your application or just output the executable.
#[serde(default)]
pub active: bool,
/// The bundle targets, currently supports ["deb", "appimage", "msi", "app", "dmg", "updater"] or "all".
/// The bundle targets, currently supports ["deb", "appimage", "nsis", "msi", "app", "dmg", "updater"] or "all".
#[serde(default)]
pub targets: BundleTarget,
/// The application identifier in reverse domain name notation (e.g. `com.tauri.example`).
Expand Down Expand Up @@ -2306,7 +2365,7 @@ 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.
/// Requires admin privileges if the installer does (WiX).
Quiet,
/// Specifies unattended mode, which means the installation only shows a progress bar.
Passive,
Expand Down Expand Up @@ -2377,6 +2436,9 @@ impl<'de> Deserialize<'de> for WindowsUpdateInstallMode {
#[cfg_attr(feature = "schema", derive(JsonSchema))]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct UpdaterWindowsConfig {
/// Additional arguments given to the NSIS or WiX installer.
#[serde(default, alias = "installer-args")]
pub installer_args: Vec<String>,
/// The installation mode for the update on Windows. Defaults to `passive`.
#[serde(default, alias = "install-mode")]
pub install_mode: WindowsUpdateInstallMode,
Expand Down Expand Up @@ -3355,7 +3417,8 @@ mod build {
impl ToTokens for UpdaterWindowsConfig {
fn to_tokens(&self, tokens: &mut TokenStream) {
let install_mode = &self.install_mode;
literal_struct!(tokens, UpdaterWindowsConfig, install_mode);
let installer_args = vec_lit(&self.installer_args, str_lit);
literal_struct!(tokens, UpdaterWindowsConfig, install_mode, installer_args);
}
}

Expand Down