Repository: tauri-apps/tauri
File: tooling/bundler/src/bundle/windows/msi/wix.rs (Rust)

Code before:
  data.insert(
    "webview_installer_args",
    to_json(if silent_webview_install {
      "/silent"
    } else {
      ""
    }),
  );

  match webview_install_mode {
    WebviewInstallMode::Skip | WebviewInstallMode::FixedRuntime { .. } => {
      data.insert("install_webview", to_json(false));
    }
    WebviewInstallMode::DownloadBootstrapper { silent: _ } => {
      data.insert("download_bootstrapper", to_json(true));
      data.insert(
        "webview_installer_args",
        to_json(if silent_webview_install {
          "&apos;/silent&apos;,"
        } else {
          ""
        }),
      );
    }
    WebviewInstallMode::EmbedBootstrapper { silent: _ } => {
      let (guid, filename) = webview2_guid_path(WEBVIEW2_BOOTSTRAPPER_URL)?;
      let online_bootstrapper_path = output_path.join(guid);
      let webview2_bootstrapper_path = online_bootstrapper_path.join(filename);
      if !webview2_bootstrapper_path.exists() {
        create_dir_all(online_bootstrapper_path)?;
        std::fs::write(
          &webview2_bootstrapper_path,
          download(WEBVIEW2_BOOTSTRAPPER_URL)?,
        )?;
      }
      data.insert(
        "webview2_bootstrapper_path",
        to_json(webview2_bootstrapper_path),
      );
    }
    WebviewInstallMode::OfflineInstaller { silent: _ } => {
      let webview2_installer_url = if arch == "x64" {
        WEBVIEW2_OFFLINE_INSTALLER_X64_URL
      } else {
        WEBVIEW2_OFFLINE_INSTALLER_X86_URL
      };
      let (guid, filename) = webview2_guid_path(webview2_installer_url)?;
      let offline_installer_path = output_path.join(arch).join(guid);
      let webview2_installer_path = offline_installer_path.join(filename);
      if !webview2_installer_path.exists() {
        create_dir_all(offline_installer_path)?;

Review comment (suggestion):
this logic of downloading the installers seems to be repeated between nsis, and wix, let's move it into a function in `util.rs`

Code after:
    "webview_installer_args",
    to_json(if silent_webview_install {
      "/silent"
    } else {
      ""
    }),
  );

  match webview_install_mode {
    WebviewInstallMode::Skip | WebviewInstallMode::FixedRuntime { .. } => {
      data.insert("install_webview", to_json(false));
    }
    WebviewInstallMode::DownloadBootstrapper { silent: _ } => {
      data.insert("download_bootstrapper", to_json(true));
      data.insert(
        "webview_installer_args",
        to_json(if silent_webview_install {
          "&apos;/silent&apos;,"
        } else {
          ""
        }),
      );
    }
    WebviewInstallMode::EmbedBootstrapper { silent: _ } => {
      let webview2_bootstrapper_path = download_webview2_bootstrapper(&output_path)?;
      data.insert(
        "webview2_bootstrapper_path",
        to_json(webview2_bootstrapper_path),
      );
    }
    WebviewInstallMode::OfflineInstaller { silent: _ } => {
      let webview2_installer_path =
        download_webview2_offline_installer(&output_path.join(arch), arch)?;
      data.insert("webview2_installer_path", to_json(webview2_installer_path));
    }
  }

  let language_map: HashMap<String, LanguageMetadata> =
    serde_json::from_str(include_str!("./languages.json")).unwrap();

  if let Some(wix) = &settings.windows().wix {
    if let Some(license) = &wix.license {
      if license.ends_with(".rtf") {
        data.insert("license", to_json(license));
      } else {
        let license_contents = read_to_string(license)?;
        let license_rtf = format!(
          r#"{{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1033{{\fonttbl{{\f0\fnil\fcharset0 Calibri;}}}}
{{\*\generator Riched20 10.0.18362}}\viewkind4\uc1
\pard\sa200\sl276\slmult1\f0\fs22\lang9 {}\par
}}