Skip to content

Commit

Permalink
feat(bundler): add option to skip webview2 runtime installation, closes
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog committed Apr 24, 2021
1 parent 73a08ab commit d13afec
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changes/wix-skip-webview-install.md
Original file line number Diff line number Diff line change
@@ -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 changes: 2 additions & 0 deletions tooling/bundler/src/bundle/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions tooling/bundler/src/bundle/templates/main.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>
Expand All @@ -185,6 +186,7 @@
<![CDATA[NOT(REMOVE OR WVRTINSTALLED)]]>
</Custom>
</InstallExecuteSequence>
{{/if}}

<SetProperty Id="ARPINSTALLLOCATION" Value="[INSTALLDIR]" After="CostFinalize"/>
</Product>
Expand Down
8 changes: 7 additions & 1 deletion tooling/bundler/src/bundle/wix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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)?;
Expand All @@ -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)?;
Expand Down
2 changes: 2 additions & 0 deletions tooling/cli.rs/config_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
4 changes: 4 additions & 0 deletions tooling/cli.rs/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1221,6 +1221,10 @@
"type": "string"
}
},
"skipWebviewInstall": {
"default": false,
"type": "boolean"
},
"template": {
"type": [
"string",
Expand Down
1 change: 1 addition & 0 deletions tooling/cli.rs/src/helpers/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
}
Expand Down

0 comments on commit d13afec

Please sign in to comment.