Skip to content

Commit 13003ec

Browse files
authored
feat(bundler): add config for WiX banner path, closes #2175 (#2448)
1 parent 7057c0f commit 13003ec

File tree

9 files changed

+53
-8
lines changed

9 files changed

+53
-8
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"tauri-bundler": patch
3+
---
4+
5+
Added `banner_path` field to the `WixSettings` struct.
6+

.changes/cli.rs-wix-banner-icon.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"cli.rs": patch
3+
---
4+
5+
Added configuration for the WiX banner icon under `tauri.conf.json > tauri > bundle > windows > wix > bannerPath`.

docs/api/config.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ In addition to the JSON defined on the `tauri.conf.json` file, Tauri reads a pla
175175
{ property: "featureRefs", optional: true, type: "string[]", description: `The Feature element ids you want to reference from the fragments.` },
176176
{ property: "mergeRefs", optional: true, type: "string[]", description: `The Merge element ids you want to reference from the fragments.` },
177177
{ property: "skipWebviewInstall", optional: true, type: "boolean", description: `Disables the Webview2 runtime installation after app install.` },
178-
{ property: "license", optional: true, type: "string", description: `The path to the license file to render on the installer. Must be an RTF file, so if a different extension is provided, we convert it to the RTF format.` }]} />
178+
{ property: "license", optional: true, type: "string", description: `The path to the license file to render on the installer. Must be an RTF file, so if a different extension is provided, we convert it to the RTF format.` },
179+
{ property: "bannerPath", optional: true, type: "string", description: `Path to a bitmap file to use as the installation user interface banner. This bitmap will appear at the top of all but the first page of the installer. The required dimensions are 493px × 58px.` }]} />
179180
}
180181
]} />
181182
},

tooling/bundler/src/bundle/settings.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,13 @@ pub struct WixSettings {
198198
pub skip_webview_install: bool,
199199
/// The path to the LICENSE file.
200200
pub license: Option<String>,
201-
/// Create an elevated update task within Windows Task Scheduler
201+
/// Create an elevated update task within Windows Task Scheduler.
202202
pub enable_elevated_update_task: bool,
203+
/// Path to a bitmap file to use as the installation user interface banner.
204+
/// This bitmap will appear at the top of all but the first page of the installer.
205+
///
206+
/// The required dimensions are 493px × 58px.
207+
pub banner_path: Option<PathBuf>,
203208
}
204209

205210
/// The Windows bundle settings.

tooling/bundler/src/bundle/windows/msi/wix.rs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,14 @@ impl ResourceDirectory {
145145

146146
/// Copies the icon to the binary path, under the `resources` folder,
147147
/// and returns the path to the file.
148-
fn copy_icon(settings: &Settings) -> crate::Result<PathBuf> {
148+
fn copy_icon(settings: &Settings, filename: &str, path: &Path) -> crate::Result<PathBuf> {
149149
let base_dir = settings.project_out_directory();
150150

151151
let resource_dir = base_dir.join("resources");
152152
std::fs::create_dir_all(&resource_dir)?;
153-
let icon_target_path = resource_dir.join("icon.ico");
153+
let icon_target_path = resource_dir.join(filename);
154154

155-
let icon_path = std::env::current_dir()?.join(&settings.windows().icon_path);
155+
let icon_path = std::env::current_dir()?.join(&path);
156156

157157
copy_file(
158158
icon_path,
@@ -504,8 +504,8 @@ pub fn build_wix_app_installer(
504504

505505
data.insert("app_exe_source", to_json(&app_exe_source));
506506

507-
// copy icon from $CWD/icons/icon.ico folder to resource folder near msi
508-
let icon_path = copy_icon(settings)?;
507+
// copy icon from `settings.windows().icon_path` folder to resource folder near msi
508+
let icon_path = copy_icon(settings, "icon.ico", &settings.windows().icon_path)?;
509509

510510
data.insert("icon_path", to_json(icon_path));
511511

@@ -533,6 +533,19 @@ pub fn build_wix_app_installer(
533533
.expect("Failed to setup custom handlebar template");
534534
has_custom_template = true;
535535
}
536+
537+
if let Some(banner_path) = &wix.banner_path {
538+
let filename = banner_path
539+
.file_name()
540+
.unwrap()
541+
.to_string_lossy()
542+
.into_owned()
543+
.to_string();
544+
data.insert(
545+
"banner_path",
546+
to_json(copy_icon(settings, &filename, banner_path)?),
547+
);
548+
}
536549
}
537550

538551
if !has_custom_template {

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131

3232
<Media Id="1" Cabinet="app.cab" EmbedCab="yes" />
3333

34-
<WixVariable Id="WixUIBannerBmp" Value="{{{icon_path}}}" />
34+
{{#if banner_path}}
35+
<WixVariable Id="WixUIBannerBmp" Value="{{{banner_path}}}" />
36+
{{/if}}
3537
{{#if license}}
3638
<WixVariable Id="WixUILicenseRtf" Value="{{{license}}}" />
3739
{{/if}}

tooling/cli.rs/config_definition.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ pub struct WixConfig {
8484
pub license: Option<String>,
8585
#[serde(default)]
8686
pub enable_elevated_update_task: bool,
87+
/// Path to a bitmap file to use as the installation user interface banner.
88+
/// This bitmap will appear at the top of all but the first page of the installer.
89+
///
90+
/// The required dimensions are 493px × 58px.
91+
pub banner_path: Option<PathBuf>,
8792
}
8893

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

tooling/cli.rs/schema.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,6 +1324,13 @@
13241324
"WixConfig": {
13251325
"type": "object",
13261326
"properties": {
1327+
"bannerPath": {
1328+
"description": "Path to a bitmap file to use as the installation user interface banner. This bitmap will appear at the top of all but the first page of the installer.\n\nThe required dimensions are 493px × 58px.",
1329+
"type": [
1330+
"string",
1331+
"null"
1332+
]
1333+
},
13271334
"componentGroupRefs": {
13281335
"default": [],
13291336
"type": "array",

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ impl From<WixConfig> for tauri_bundler::WixSettings {
2525
skip_webview_install: config.skip_webview_install,
2626
license: config.license,
2727
enable_elevated_update_task: config.enable_elevated_update_task,
28+
banner_path: config.banner_path,
2829
}
2930
}
3031
}

0 commit comments

Comments
 (0)