Skip to content

Commit d13afec

Browse files
authored
feat(bundler): add option to skip webview2 runtime installation, closes #1606 (#1612)
1 parent 73a08ab commit d13afec

File tree

7 files changed

+23
-1
lines changed

7 files changed

+23
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri-bundler": patch
3+
---
4+
5+
Adds `skip_webview_install` config under `windows > wix` to disable Webview2 runtime installation after the app install.

tooling/bundler/src/bundle/settings.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ pub struct WixSettings {
184184
pub feature_refs: Vec<String>,
185185
#[serde(default)]
186186
pub merge_refs: Vec<String>,
187+
#[serde(default)]
188+
pub skip_webview_install: bool,
187189
}
188190

189191
/// The Windows bundle settings.

tooling/bundler/src/bundle/templates/main.wxs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@
175175
{{/each~}}
176176
</Feature>
177177

178+
{{#if install_webview}}
178179
<!-- WebView2 -->
179180
<Property Id="WVRTINSTALLED">
180181
<RegistrySearch Id="WVRTInstalled" Root="HKLM" Key="SOFTWARE\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" Name="pv" Type="raw" Win64="no"/>
@@ -185,6 +186,7 @@
185186
<![CDATA[NOT(REMOVE OR WVRTINSTALLED)]]>
186187
</Custom>
187188
</InstallExecuteSequence>
189+
{{/if}}
188190

189191
<SetProperty Id="ARPINSTALLLOCATION" Value="[INSTALLDIR]" After="CostFinalize"/>
190192
</Product>

tooling/bundler/src/bundle/wix.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@ pub fn build_wix_app_installer(
466466
let mut fragment_paths = Vec::new();
467467
let mut handlebars = Handlebars::new();
468468
let mut has_custom_template = false;
469+
let mut install_webview = true;
469470

470471
if let Some(wix) = &settings.windows().wix {
471472
data.insert("component_group_refs", to_json(&wix.component_group_refs));
@@ -474,6 +475,7 @@ pub fn build_wix_app_installer(
474475
data.insert("feature_refs", to_json(&wix.feature_refs));
475476
data.insert("merge_refs", to_json(&wix.merge_refs));
476477
fragment_paths = wix.fragment_paths.clone();
478+
install_webview = !wix.skip_webview_install;
477479

478480
if let Some(temp_path) = &wix.template {
479481
let template = std::fs::read_to_string(temp_path)?;
@@ -490,7 +492,11 @@ pub fn build_wix_app_installer(
490492
.register_template_string("main.wxs", include_str!("templates/main.wxs"))
491493
.map_err(|e| e.to_string())
492494
.expect("Failed to setup handlebar template");
493-
};
495+
}
496+
497+
if install_webview {
498+
data.insert("install_webview", to_json(true));
499+
}
494500

495501
if output_path.exists() {
496502
remove_dir_all(&output_path)?;

tooling/cli.rs/config_definition.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ pub struct WixConfig {
5757
pub feature_refs: Vec<String>,
5858
#[serde(default)]
5959
pub merge_refs: Vec<String>,
60+
#[serde(default)]
61+
pub skip_webview_install: bool,
6062
}
6163

6264
#[derive(Debug, Default, PartialEq, Clone, Deserialize, Serialize, JsonSchema)]

tooling/cli.rs/schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,6 +1221,10 @@
12211221
"type": "string"
12221222
}
12231223
},
1224+
"skipWebviewInstall": {
1225+
"default": false,
1226+
"type": "boolean"
1227+
},
12241228
"template": {
12251229
"type": [
12261230
"string",

tooling/cli.rs/src/helpers/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ impl From<WixConfig> for tauri_bundler::WixSettings {
2323
feature_group_refs: config.feature_group_refs,
2424
feature_refs: config.feature_refs,
2525
merge_refs: config.merge_refs,
26+
skip_webview_install: config.skip_webview_install,
2627
}
2728
}
2829
}

0 commit comments

Comments
 (0)