Эх сурвалжийг харах

feat(bundler): add option to skip webview2 runtime installation, closes #1606 (#1612)

Lucas Fernandes Nogueira 4 жил өмнө
parent
commit
d13afec204

+ 5 - 0
.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.

+ 2 - 0
tooling/bundler/src/bundle/settings.rs

@@ -184,6 +184,8 @@ pub struct WixSettings {
   pub feature_refs: Vec<String>,
   #[serde(default)]
   pub merge_refs: Vec<String>,
+  #[serde(default)]
+  pub skip_webview_install: bool,
 }
 
 /// The Windows bundle settings.

+ 2 - 0
tooling/bundler/src/bundle/templates/main.wxs

@@ -175,6 +175,7 @@
             {{/each~}}
         </Feature>
 
+        {{#if install_webview}}
         <!-- WebView2 -->
         <Property Id="WVRTINSTALLED">
             <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 @@
                 <![CDATA[NOT(REMOVE OR WVRTINSTALLED)]]>
             </Custom>
         </InstallExecuteSequence>
+        {{/if}}
 
         <SetProperty Id="ARPINSTALLLOCATION" Value="[INSTALLDIR]" After="CostFinalize"/>        
     </Product>

+ 7 - 1
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)?;

+ 2 - 0
tooling/cli.rs/config_definition.rs

@@ -57,6 +57,8 @@ pub struct WixConfig {
   pub feature_refs: Vec<String>,
   #[serde(default)]
   pub merge_refs: Vec<String>,
+  #[serde(default)]
+  pub skip_webview_install: bool,
 }
 
 #[derive(Debug, Default, PartialEq, Clone, Deserialize, Serialize, JsonSchema)]

+ 4 - 0
tooling/cli.rs/schema.json

@@ -1221,6 +1221,10 @@
             "type": "string"
           }
         },
+        "skipWebviewInstall": {
+          "default": false,
+          "type": "boolean"
+        },
         "template": {
           "type": [
             "string",

+ 1 - 0
tooling/cli.rs/src/helpers/config.rs

@@ -23,6 +23,7 @@ impl From<WixConfig> 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,
     }
   }
 }