Skip to content

Commit 5dc2cee

Browse files
fea(wix): add minimum webview2 version support (#14793)
* feat(wix): add minimum webview2 version option * Add change file * Format * Move comments inside `#if` block * add breaking change notes * Add deprecation to description schema * Merge remote-tracking branch 'upstream/dev' into wix-minimum-webview2-version * Merge branch 'dev' into wix-minimum-webview2-version
1 parent 3b5b2cc commit 5dc2cee

10 files changed

Lines changed: 102 additions & 11 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
"tauri-bundler": minor:feat
3+
"tauri-cli": minor:feat
4+
"@tauri-apps/cli": minor:feat
5+
---
6+
7+
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`
8+
9+
Notes:
10+
11+
- For anyone relying on the `WVRTINSTALLED` `Property` tag in `main.wxs`, it is now renamed to `INSTALLED_WEBVIEW2_VERSION`
12+
- For `tauri-bundler` lib users, the `WindowsSettings` now has a new field `minimum_webview2_version` which can be a breaking change

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,10 @@ pub struct NsisSettings {
532532
/// Try to ensure that the WebView2 version is equal to or newer than this version,
533533
/// if the user's WebView2 is older than this version,
534534
/// the installer will try to trigger a WebView2 update.
535+
#[deprecated(
536+
since = "2.8.0",
537+
note = "Use `WindowsSettings::minimum_webview2_version` instead."
538+
)]
535539
pub minimum_webview2_version: Option<String>,
536540
}
537541

@@ -587,6 +591,10 @@ pub struct WindowsSettings {
587591
/// if you are on another platform and want to cross-compile and sign you will
588592
/// need to use another tool like `osslsigncode`.
589593
pub sign_command: Option<CustomSignCommandSettings>,
594+
/// Try to ensure that the WebView2 version is equal to or newer than this version,
595+
/// if the user's WebView2 is older than this version,
596+
/// the installer will try to trigger a WebView2 update.
597+
pub minimum_webview2_version: Option<String>,
590598
}
591599

592600
impl WindowsSettings {
@@ -612,6 +620,7 @@ mod _default {
612620
webview_install_mode: Default::default(),
613621
allow_downgrades: true,
614622
sign_command: None,
623+
minimum_webview2_version: None,
615624
}
616625
}
617626
}

crates/tauri-bundler/src/bundle/windows/msi/main.wxs

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -283,38 +283,62 @@
283283

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

291292
{{#if download_bootstrapper}}
293+
<!-- Download webview bootstrapper mode -->
292294
<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'/>
293295
<InstallExecuteSequence>
294296
<Custom Action='DownloadAndInvokeBootstrapper' Before='InstallFinalize'>
295-
<![CDATA[NOT(REMOVE OR WVRTINSTALLED)]]>
297+
<![CDATA[NOT(REMOVE OR INSTALLED_WEBVIEW2_VERSION)]]>
296298
</Custom>
297299
</InstallExecuteSequence>
298300
{{/if}}
299301

300-
<!-- Embedded webview bootstrapper mode -->
301302
{{#if webview2_bootstrapper_path}}
303+
<!-- Embedded webview bootstrapper mode -->
302304
<Binary Id="MicrosoftEdgeWebview2Setup.exe" SourceFile="{{webview2_bootstrapper_path}}"/>
303305
<CustomAction Id='InvokeBootstrapper' BinaryKey='MicrosoftEdgeWebview2Setup.exe' Execute="deferred" ExeCommand='{{webview_installer_args}} /install' Return='check' />
304306
<InstallExecuteSequence>
305307
<Custom Action='InvokeBootstrapper' Before='InstallFinalize'>
306-
<![CDATA[NOT(REMOVE OR WVRTINSTALLED)]]>
308+
<![CDATA[NOT(REMOVE OR INSTALLED_WEBVIEW2_VERSION)]]>
307309
</Custom>
308310
</InstallExecuteSequence>
309311
{{/if}}
310312

311-
<!-- Embedded offline installer -->
312313
{{#if webview2_installer_path}}
314+
<!-- Embedded offline installer -->
313315
<Binary Id="MicrosoftEdgeWebView2RuntimeInstaller.exe" SourceFile="{{webview2_installer_path}}"/>
314316
<CustomAction Id='InvokeStandalone' BinaryKey='MicrosoftEdgeWebView2RuntimeInstaller.exe' Execute="deferred" ExeCommand='{{webview_installer_args}} /install' Return='check' />
315317
<InstallExecuteSequence>
316318
<Custom Action='InvokeStandalone' Before='InstallFinalize'>
317-
<![CDATA[NOT(REMOVE OR WVRTINSTALLED)]]>
319+
<![CDATA[NOT(REMOVE OR INSTALLED_WEBVIEW2_VERSION)]]>
320+
</Custom>
321+
</InstallExecuteSequence>
322+
{{/if}}
323+
324+
{{#if minimum_webview2_version}}
325+
<!-- Update WebView2 if minimum version requirement not met -->
326+
<Property Id="MINIMUM_WEBVIEW2_VERSION" Value="{{minimum_webview2_version}}" />
327+
<Property Id="EDGEUPDATE_PATH">
328+
<RegistrySearch Id="EdgeUpdateLocalMachine64" Root="HKLM" Key="SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate" Name="path" Type="raw" />
329+
<RegistrySearch Id="EdgeUpdateLocalMachine32" Root="HKLM" Key="SOFTWARE\Microsoft\EdgeUpdate" Name="path" Type="raw"/>
330+
<RegistrySearch Id="EdgeUpdateCurrentUser" Root="HKCU" Key="SOFTWARE\Microsoft\EdgeUpdate" Name="path" Type="raw"/>
331+
</Property>
332+
<!-- Chromium updater docs: https://source.chromium.org/chromium/chromium/src/+/main:docs/updater/user_manual.md -->
333+
<!-- Modified from "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft EdgeWebView\ModifyPath" -->
334+
<CustomAction Id="UpdateWebView2ViaEdgeUpdate" Execute="deferred" Property="EDGEUPDATE_PATH" Return="check" Impersonate="no" ExeCommand="/install appguid={F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}&amp;needsadmin=true" />
335+
<InstallExecuteSequence>
336+
<Custom Action='UpdateWebView2ViaEdgeUpdate' Before='InstallFinalize'>
337+
<![CDATA[
338+
NOT REMOVE
339+
AND INSTALLED_WEBVIEW2_VERSION
340+
AND (INSTALLED_WEBVIEW2_VERSION < MINIMUM_WEBVIEW2_VERSION)
341+
]]>
318342
</Custom>
319343
</InstallExecuteSequence>
320344
{{/if}}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,13 @@ pub fn build_wix_app_installer(
532532
}
533533
}
534534

535+
if let Some(minimum_webview2_version) = &settings.windows().minimum_webview2_version {
536+
data.insert(
537+
"minimum_webview2_version",
538+
to_json(minimum_webview2_version),
539+
);
540+
}
541+
535542
if let Some(license) = settings.license_file() {
536543
if license.ends_with(".rtf") {
537544
data.insert("license", to_json(license));

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,12 @@ fn build_nsis_app_installer(
362362
if let Some(start_menu_folder) = &nsis.start_menu_folder {
363363
data.insert("start_menu_folder", to_json(start_menu_folder));
364364
}
365-
if let Some(minimum_webview2_version) = &nsis.minimum_webview2_version {
365+
#[allow(deprecated)]
366+
if let Some(minimum_webview2_version) = nsis
367+
.minimum_webview2_version
368+
.as_ref()
369+
.or(settings.windows().minimum_webview2_version.as_ref())
370+
{
366371
data.insert(
367372
"minimum_webview2_version",
368373
to_json(minimum_webview2_version),

crates/tauri-cli/config.schema.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@
131131
"allowDowngrades": true,
132132
"certificateThumbprint": null,
133133
"digestAlgorithm": null,
134+
"minimumWebview2Version": null,
134135
"nsis": null,
135136
"signCommand": null,
136137
"timestampUrl": null,
@@ -2225,6 +2226,7 @@
22252226
"allowDowngrades": true,
22262227
"certificateThumbprint": null,
22272228
"digestAlgorithm": null,
2229+
"minimumWebview2Version": null,
22282230
"nsis": null,
22292231
"signCommand": null,
22302232
"timestampUrl": null,
@@ -2667,6 +2669,13 @@
26672669
"default": true,
26682670
"type": "boolean"
26692671
},
2672+
"minimumWebview2Version": {
2673+
"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.",
2674+
"type": [
2675+
"string",
2676+
"null"
2677+
]
2678+
},
26702679
"wix": {
26712680
"description": "Configuration for the MSI generated with WiX.",
26722681
"anyOf": [
@@ -3045,7 +3054,8 @@
30453054
]
30463055
},
30473056
"minimumWebview2Version": {
3048-
"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.",
3057+
"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.",
3058+
"deprecated": true,
30493059
"type": [
30503060
"string",
30513061
"null"

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ pub fn nsis_settings(config: NsisConfig) -> tauri_bundler::NsisSettings {
117117
compression: config.compression,
118118
start_menu_folder: config.start_menu_folder,
119119
installer_hooks: config.installer_hooks,
120+
#[allow(deprecated)]
120121
minimum_webview2_version: config.minimum_webview2_version,
121122
}
122123
}

crates/tauri-cli/src/interface/rust.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,6 +1657,7 @@ fn tauri_config_to_bundle_settings(
16571657
webview_install_mode: config.windows.webview_install_mode,
16581658
allow_downgrades: config.windows.allow_downgrades,
16591659
sign_command: config.windows.sign_command.map(custom_sign_settings),
1660+
minimum_webview2_version: config.windows.minimum_webview2_version,
16601661
},
16611662
license: config.license.or_else(|| {
16621663
settings

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@
131131
"allowDowngrades": true,
132132
"certificateThumbprint": null,
133133
"digestAlgorithm": null,
134+
"minimumWebview2Version": null,
134135
"nsis": null,
135136
"signCommand": null,
136137
"timestampUrl": null,
@@ -2225,6 +2226,7 @@
22252226
"allowDowngrades": true,
22262227
"certificateThumbprint": null,
22272228
"digestAlgorithm": null,
2229+
"minimumWebview2Version": null,
22282230
"nsis": null,
22292231
"signCommand": null,
22302232
"timestampUrl": null,
@@ -2667,6 +2669,13 @@
26672669
"default": true,
26682670
"type": "boolean"
26692671
},
2672+
"minimumWebview2Version": {
2673+
"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.",
2674+
"type": [
2675+
"string",
2676+
"null"
2677+
]
2678+
},
26702679
"wix": {
26712680
"description": "Configuration for the MSI generated with WiX.",
26722681
"anyOf": [
@@ -3045,7 +3054,8 @@
30453054
]
30463055
},
30473056
"minimumWebview2Version": {
3048-
"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.",
3057+
"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.",
3058+
"deprecated": true,
30493059
"type": [
30503060
"string",
30513061
"null"

crates/tauri-utils/src/config.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,9 +926,15 @@ pub struct NsisConfig {
926926
/// ```
927927
#[serde(alias = "installer-hooks")]
928928
pub installer_hooks: Option<PathBuf>,
929+
/// Deprecated: use [`WindowsConfig::minimum_webview2_version`] (`bundle > windows > minimumWebview2Version`) instead.
930+
///
929931
/// Try to ensure that the WebView2 version is equal to or newer than this version,
930932
/// if the user's WebView2 is older than this version,
931933
/// the installer will try to trigger a WebView2 update.
934+
#[deprecated(
935+
since = "2.10.0",
936+
note = "Use `WindowsConfig::minimum_webview2_version` instead."
937+
)]
932938
#[serde(alias = "minimum-webview2-version")]
933939
pub minimum_webview2_version: Option<String>,
934940
}
@@ -1043,6 +1049,11 @@ pub struct WindowsConfig {
10431049
/// The default value of this flag is `true`.
10441050
#[serde(default = "default_true", alias = "allow-downgrades")]
10451051
pub allow_downgrades: bool,
1052+
/// Try to ensure that the WebView2 version is equal to or newer than this version,
1053+
/// if the user's WebView2 is older than this version,
1054+
/// the installer will try to trigger a WebView2 update.
1055+
#[serde(alias = "minimum-webview2-version")]
1056+
pub minimum_webview2_version: Option<String>,
10461057
/// Configuration for the MSI generated with WiX.
10471058
pub wix: Option<WixConfig>,
10481059
/// Configuration for the installer generated with NSIS.
@@ -1067,6 +1078,7 @@ impl Default for WindowsConfig {
10671078
tsp: false,
10681079
webview_install_mode: Default::default(),
10691080
allow_downgrades: true,
1081+
minimum_webview2_version: None,
10701082
wix: None,
10711083
nsis: None,
10721084
sign_command: None,

0 commit comments

Comments
 (0)