From d13afec20402b8ddbbf3ceb4349edb1956ed79bc Mon Sep 17 00:00:00 2001 From: Lucas Fernandes Nogueira Date: Sat, 24 Apr 2021 19:01:50 -0300 Subject: [PATCH] feat(bundler): add option to skip webview2 runtime installation, closes #1606 (#1612) --- .changes/wix-skip-webview-install.md | 5 +++++ tooling/bundler/src/bundle/settings.rs | 2 ++ tooling/bundler/src/bundle/templates/main.wxs | 2 ++ tooling/bundler/src/bundle/wix.rs | 8 +++++++- tooling/cli.rs/config_definition.rs | 2 ++ tooling/cli.rs/schema.json | 4 ++++ tooling/cli.rs/src/helpers/config.rs | 1 + 7 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 .changes/wix-skip-webview-install.md diff --git a/.changes/wix-skip-webview-install.md b/.changes/wix-skip-webview-install.md new file mode 100644 index 000000000..aa0514ee6 --- /dev/null +++ b/.changes/wix-skip-webview-install.md @@ -0,0 +1,5 @@ +--- +"tauri-bundler": patch +--- + +Adds `skip_webview_install` config under `windows > wix` to disable Webview2 runtime installation after the app install. diff --git a/tooling/bundler/src/bundle/settings.rs b/tooling/bundler/src/bundle/settings.rs index 8a5db7ce8..626596516 100644 --- a/tooling/bundler/src/bundle/settings.rs +++ b/tooling/bundler/src/bundle/settings.rs @@ -184,6 +184,8 @@ pub struct WixSettings { pub feature_refs: Vec, #[serde(default)] pub merge_refs: Vec, + #[serde(default)] + pub skip_webview_install: bool, } /// The Windows bundle settings. diff --git a/tooling/bundler/src/bundle/templates/main.wxs b/tooling/bundler/src/bundle/templates/main.wxs index cbf0dc397..c0c1758ee 100644 --- a/tooling/bundler/src/bundle/templates/main.wxs +++ b/tooling/bundler/src/bundle/templates/main.wxs @@ -175,6 +175,7 @@ {{/each~}} + {{#if install_webview}} @@ -185,6 +186,7 @@ + {{/if}} diff --git a/tooling/bundler/src/bundle/wix.rs b/tooling/bundler/src/bundle/wix.rs index f3a997388..ffb1fd05b 100644 --- a/tooling/bundler/src/bundle/wix.rs +++ b/tooling/bundler/src/bundle/wix.rs @@ -466,6 +466,7 @@ pub fn build_wix_app_installer( let mut fragment_paths = Vec::new(); let mut handlebars = Handlebars::new(); let mut has_custom_template = false; + let mut install_webview = true; if let Some(wix) = &settings.windows().wix { data.insert("component_group_refs", to_json(&wix.component_group_refs)); @@ -474,6 +475,7 @@ pub fn build_wix_app_installer( data.insert("feature_refs", to_json(&wix.feature_refs)); data.insert("merge_refs", to_json(&wix.merge_refs)); fragment_paths = wix.fragment_paths.clone(); + install_webview = !wix.skip_webview_install; if let Some(temp_path) = &wix.template { let template = std::fs::read_to_string(temp_path)?; @@ -490,7 +492,11 @@ pub fn build_wix_app_installer( .register_template_string("main.wxs", include_str!("templates/main.wxs")) .map_err(|e| e.to_string()) .expect("Failed to setup handlebar template"); - }; + } + + if install_webview { + data.insert("install_webview", to_json(true)); + } if output_path.exists() { remove_dir_all(&output_path)?; diff --git a/tooling/cli.rs/config_definition.rs b/tooling/cli.rs/config_definition.rs index b58fbdc24..ee7ca4641 100644 --- a/tooling/cli.rs/config_definition.rs +++ b/tooling/cli.rs/config_definition.rs @@ -57,6 +57,8 @@ pub struct WixConfig { pub feature_refs: Vec, #[serde(default)] pub merge_refs: Vec, + #[serde(default)] + pub skip_webview_install: bool, } #[derive(Debug, Default, PartialEq, Clone, Deserialize, Serialize, JsonSchema)] diff --git a/tooling/cli.rs/schema.json b/tooling/cli.rs/schema.json index 91b76feb1..845cdc84d 100644 --- a/tooling/cli.rs/schema.json +++ b/tooling/cli.rs/schema.json @@ -1221,6 +1221,10 @@ "type": "string" } }, + "skipWebviewInstall": { + "default": false, + "type": "boolean" + }, "template": { "type": [ "string", diff --git a/tooling/cli.rs/src/helpers/config.rs b/tooling/cli.rs/src/helpers/config.rs index 7760c3d45..2d876270d 100644 --- a/tooling/cli.rs/src/helpers/config.rs +++ b/tooling/cli.rs/src/helpers/config.rs @@ -23,6 +23,7 @@ impl From for tauri_bundler::WixSettings { feature_group_refs: config.feature_group_refs, feature_refs: config.feature_refs, merge_refs: config.merge_refs, + skip_webview_install: config.skip_webview_install, } } }