Skip to content
Open
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
12 changes: 12 additions & 0 deletions .changes/wix-minimum-webview2-version.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"tauri-bundler": minor:feat
"tauri-cli": minor:feat
"@tauri-apps/cli": minor:feat
---

Added support for `minimumWebview2Version` option support for the MSI (Wix) installer, the old `bundle > windows > nsis > minimumWebview2Version` is now deprecated in favor of `bundle > windows > minimumWebview2Version`

Notes:

- For anyone relying on the `WVRTINSTALLED` `Property` tag in `main.wxs`, it is now renamed to `INSTALLED_WEBVIEW2_VERSION`
- For `tauri-bundler` lib users, the `WindowsSettings` now has a new field `minimum_webview2_version` which can be a breaking change
9 changes: 9 additions & 0 deletions crates/tauri-bundler/src/bundle/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,10 @@ pub struct NsisSettings {
/// Try to ensure that the WebView2 version is equal to or newer than this version,
/// if the user's WebView2 is older than this version,
/// the installer will try to trigger a WebView2 update.
#[deprecated(
since = "2.8.0",
note = "Use `WindowsSettings::minimum_webview2_version` instead."
)]
pub minimum_webview2_version: Option<String>,
}

Expand Down Expand Up @@ -587,6 +591,10 @@ pub struct WindowsSettings {
/// if you are on another platform and want to cross-compile and sign you will
/// need to use another tool like `osslsigncode`.
pub sign_command: Option<CustomSignCommandSettings>,
/// Try to ensure that the WebView2 version is equal to or newer than this version,
/// if the user's WebView2 is older than this version,
/// the installer will try to trigger a WebView2 update.
pub minimum_webview2_version: Option<String>,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a field here is technically breaking as well...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any better idea than making it all Builder patterns in v3?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

marking minors as breaking? 😂

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

time to stop using semver

}

impl WindowsSettings {
Expand All @@ -612,6 +620,7 @@ mod _default {
webview_install_mode: Default::default(),
allow_downgrades: true,
sign_command: None,
minimum_webview2_version: None,
}
}
}
Expand Down
40 changes: 32 additions & 8 deletions crates/tauri-bundler/src/bundle/windows/msi/main.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -279,38 +279,62 @@

{{#if install_webview}}
<!-- WebView2 -->
<Property Id="WVRTINSTALLED">
<RegistrySearch Id="WVRTInstalledSystem" Root="HKLM" Key="SOFTWARE\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" Name="pv" Type="raw" Win64="no" />
<RegistrySearch Id="WVRTInstalledUser" Root="HKCU" Key="SOFTWARE\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" Name="pv" Type="raw"/>
<Property Id="INSTALLED_WEBVIEW2_VERSION">
<RegistrySearch Id="Webview2VersionSystemx64" Root="HKLM" Key="SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" Name="pv" Type="raw" />
<RegistrySearch Id="Webview2VersionSystemx86" Root="HKLM" Key="SOFTWARE\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" Name="pv" Type="raw" />
<RegistrySearch Id="Webview2VersionUser" Root="HKCU" Key="SOFTWARE\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" Name="pv" Type="raw"/>
</Property>

{{#if download_bootstrapper}}
<!-- Download webview bootstrapper mode -->
<CustomAction Id='DownloadAndInvokeBootstrapper' Directory="INSTALLDIR" Execute="deferred" ExeCommand='powershell.exe -NoProfile -windowstyle hidden try [\{] [\[]Net.ServicePointManager[\]]::SecurityProtocol = [\[]Net.SecurityProtocolType[\]]::Tls12 [\}] catch [\{][\}]; Invoke-WebRequest -Uri "https://go.microsoft.com/fwlink/p/?LinkId=2124703" -OutFile "$env:TEMP\MicrosoftEdgeWebview2Setup.exe" ; Start-Process -FilePath "$env:TEMP\MicrosoftEdgeWebview2Setup.exe" -ArgumentList ({{webview_installer_args}} &apos;/install&apos;) -Wait' Return='check'/>
<InstallExecuteSequence>
<Custom Action='DownloadAndInvokeBootstrapper' Before='InstallFinalize'>
<![CDATA[NOT(REMOVE OR WVRTINSTALLED)]]>
<![CDATA[NOT(REMOVE OR INSTALLED_WEBVIEW2_VERSION)]]>
</Custom>
</InstallExecuteSequence>
{{/if}}

<!-- Embedded webview bootstrapper mode -->
{{#if webview2_bootstrapper_path}}
<!-- Embedded webview bootstrapper mode -->
<Binary Id="MicrosoftEdgeWebview2Setup.exe" SourceFile="{{webview2_bootstrapper_path}}"/>
<CustomAction Id='InvokeBootstrapper' BinaryKey='MicrosoftEdgeWebview2Setup.exe' Execute="deferred" ExeCommand='{{webview_installer_args}} /install' Return='check' />
<InstallExecuteSequence>
<Custom Action='InvokeBootstrapper' Before='InstallFinalize'>
<![CDATA[NOT(REMOVE OR WVRTINSTALLED)]]>
<![CDATA[NOT(REMOVE OR INSTALLED_WEBVIEW2_VERSION)]]>
</Custom>
</InstallExecuteSequence>
{{/if}}

<!-- Embedded offline installer -->
{{#if webview2_installer_path}}
<!-- Embedded offline installer -->
<Binary Id="MicrosoftEdgeWebView2RuntimeInstaller.exe" SourceFile="{{webview2_installer_path}}"/>
<CustomAction Id='InvokeStandalone' BinaryKey='MicrosoftEdgeWebView2RuntimeInstaller.exe' Execute="deferred" ExeCommand='{{webview_installer_args}} /install' Return='check' />
<InstallExecuteSequence>
<Custom Action='InvokeStandalone' Before='InstallFinalize'>
<![CDATA[NOT(REMOVE OR WVRTINSTALLED)]]>
<![CDATA[NOT(REMOVE OR INSTALLED_WEBVIEW2_VERSION)]]>
</Custom>
</InstallExecuteSequence>
{{/if}}

{{#if minimum_webview2_version}}
<!-- Update WebView2 if minimum version requirement not met -->
<Property Id="MINIMUM_WEBVIEW2_VERSION" Value="{{minimum_webview2_version}}" />
<Property Id="EDGEUPDATE_PATH">
<RegistrySearch Id="EdgeUpdateLocalMachine64" Root="HKLM" Key="SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate" Name="path" Type="raw" />
<RegistrySearch Id="EdgeUpdateLocalMachine32" Root="HKLM" Key="SOFTWARE\Microsoft\EdgeUpdate" Name="path" Type="raw"/>
<RegistrySearch Id="EdgeUpdateCurrentUser" Root="HKCU" Key="SOFTWARE\Microsoft\EdgeUpdate" Name="path" Type="raw"/>
</Property>
<!-- Chromium updater docs: https://source.chromium.org/chromium/chromium/src/+/main:docs/updater/user_manual.md -->
<!-- Modified from "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft EdgeWebView\ModifyPath" -->
<CustomAction Id="UpdateWebView2ViaEdgeUpdate" Execute="deferred" Property="EDGEUPDATE_PATH" Return="check" Impersonate="no" ExeCommand="/install appguid={F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}&amp;needsadmin=true" />
<InstallExecuteSequence>
<Custom Action='UpdateWebView2ViaEdgeUpdate' Before='InstallFinalize'>
<![CDATA[
NOT REMOVE
AND INSTALLED_WEBVIEW2_VERSION
AND (INSTALLED_WEBVIEW2_VERSION < MINIMUM_WEBVIEW2_VERSION)
]]>
</Custom>
</InstallExecuteSequence>
{{/if}}
Expand Down
7 changes: 7 additions & 0 deletions crates/tauri-bundler/src/bundle/windows/msi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,13 @@ pub fn build_wix_app_installer(
}
}

if let Some(minimum_webview2_version) = &settings.windows().minimum_webview2_version {
data.insert(
"minimum_webview2_version",
to_json(minimum_webview2_version),
);
}

if let Some(license) = settings.license_file() {
if license.ends_with(".rtf") {
data.insert("license", to_json(license));
Expand Down
7 changes: 6 additions & 1 deletion crates/tauri-bundler/src/bundle/windows/nsis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,12 @@ fn build_nsis_app_installer(
if let Some(start_menu_folder) = &nsis.start_menu_folder {
data.insert("start_menu_folder", to_json(start_menu_folder));
}
if let Some(minimum_webview2_version) = &nsis.minimum_webview2_version {
#[allow(deprecated)]
if let Some(minimum_webview2_version) = nsis
.minimum_webview2_version
.as_ref()
.or(settings.windows().minimum_webview2_version.as_ref())
{
data.insert(
"minimum_webview2_version",
to_json(minimum_webview2_version),
Expand Down
12 changes: 11 additions & 1 deletion crates/tauri-cli/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
"allowDowngrades": true,
"certificateThumbprint": null,
"digestAlgorithm": null,
"minimumWebview2Version": null,
"nsis": null,
"signCommand": null,
"timestampUrl": null,
Expand Down Expand Up @@ -2204,6 +2205,7 @@
"allowDowngrades": true,
"certificateThumbprint": null,
"digestAlgorithm": null,
"minimumWebview2Version": null,
"nsis": null,
"signCommand": null,
"timestampUrl": null,
Expand Down Expand Up @@ -2646,6 +2648,13 @@
"default": true,
"type": "boolean"
},
"minimumWebview2Version": {
"description": "Try to ensure that the WebView2 version is equal to or newer than this version,\n if the user's WebView2 is older than this version,\n the installer will try to trigger a WebView2 update.",
"type": [
"string",
"null"
]
},
"wix": {
"description": "Configuration for the MSI generated with WiX.",
"anyOf": [
Expand Down Expand Up @@ -3024,7 +3033,8 @@
]
},
"minimumWebview2Version": {
"description": "Try to ensure that the WebView2 version is equal to or newer than this version,\n if the user's WebView2 is older than this version,\n the installer will try to trigger a WebView2 update.",
"description": "Deprecated: use [`WindowsConfig::minimum_webview2_version`] (`bundle > windows > minimumWebview2Version`) instead.\n\n Try to ensure that the WebView2 version is equal to or newer than this version,\n if the user's WebView2 is older than this version,\n the installer will try to trigger a WebView2 update.",
"deprecated": true,
"type": [
"string",
"null"
Expand Down
1 change: 1 addition & 0 deletions crates/tauri-cli/src/helpers/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ pub fn nsis_settings(config: NsisConfig) -> tauri_bundler::NsisSettings {
compression: config.compression,
start_menu_folder: config.start_menu_folder,
installer_hooks: config.installer_hooks,
#[allow(deprecated)]
minimum_webview2_version: config.minimum_webview2_version,
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/tauri-cli/src/interface/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1650,6 +1650,7 @@ fn tauri_config_to_bundle_settings(
webview_install_mode: config.windows.webview_install_mode,
allow_downgrades: config.windows.allow_downgrades,
sign_command: config.windows.sign_command.map(custom_sign_settings),
minimum_webview2_version: config.windows.minimum_webview2_version,
},
license: config.license.or_else(|| {
settings
Expand Down
12 changes: 11 additions & 1 deletion crates/tauri-schema-generator/schemas/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
"allowDowngrades": true,
"certificateThumbprint": null,
"digestAlgorithm": null,
"minimumWebview2Version": null,
"nsis": null,
"signCommand": null,
"timestampUrl": null,
Expand Down Expand Up @@ -2204,6 +2205,7 @@
"allowDowngrades": true,
"certificateThumbprint": null,
"digestAlgorithm": null,
"minimumWebview2Version": null,
"nsis": null,
"signCommand": null,
"timestampUrl": null,
Expand Down Expand Up @@ -2646,6 +2648,13 @@
"default": true,
"type": "boolean"
},
"minimumWebview2Version": {
"description": "Try to ensure that the WebView2 version is equal to or newer than this version,\n if the user's WebView2 is older than this version,\n the installer will try to trigger a WebView2 update.",
"type": [
"string",
"null"
]
},
"wix": {
"description": "Configuration for the MSI generated with WiX.",
"anyOf": [
Expand Down Expand Up @@ -3024,7 +3033,8 @@
]
},
"minimumWebview2Version": {
"description": "Try to ensure that the WebView2 version is equal to or newer than this version,\n if the user's WebView2 is older than this version,\n the installer will try to trigger a WebView2 update.",
"description": "Deprecated: use [`WindowsConfig::minimum_webview2_version`] (`bundle > windows > minimumWebview2Version`) instead.\n\n Try to ensure that the WebView2 version is equal to or newer than this version,\n if the user's WebView2 is older than this version,\n the installer will try to trigger a WebView2 update.",
"deprecated": true,
"type": [
"string",
"null"
Expand Down
12 changes: 12 additions & 0 deletions crates/tauri-utils/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -926,9 +926,15 @@ pub struct NsisConfig {
/// ```
#[serde(alias = "installer-hooks")]
pub installer_hooks: Option<PathBuf>,
/// Deprecated: use [`WindowsConfig::minimum_webview2_version`] (`bundle > windows > minimumWebview2Version`) instead.
///
/// Try to ensure that the WebView2 version is equal to or newer than this version,
/// if the user's WebView2 is older than this version,
/// the installer will try to trigger a WebView2 update.
#[deprecated(
since = "2.10.0",
note = "Use `WindowsConfig::minimum_webview2_version` instead."
)]
#[serde(alias = "minimum-webview2-version")]
pub minimum_webview2_version: Option<String>,
}
Expand Down Expand Up @@ -1043,6 +1049,11 @@ pub struct WindowsConfig {
/// The default value of this flag is `true`.
#[serde(default = "default_true", alias = "allow-downgrades")]
pub allow_downgrades: bool,
/// Try to ensure that the WebView2 version is equal to or newer than this version,
/// if the user's WebView2 is older than this version,
/// the installer will try to trigger a WebView2 update.
#[serde(alias = "minimum-webview2-version")]
pub minimum_webview2_version: Option<String>,
/// Configuration for the MSI generated with WiX.
pub wix: Option<WixConfig>,
/// Configuration for the installer generated with NSIS.
Expand All @@ -1067,6 +1078,7 @@ impl Default for WindowsConfig {
tsp: false,
webview_install_mode: Default::default(),
allow_downgrades: true,
minimum_webview2_version: None,
wix: None,
nsis: None,
sign_command: None,
Expand Down
Loading