Skip to content

Commit a547971

Browse files
authored
fix(build): always invoke resource compiler on windows, fixes #8164 (#8168)
* fix(build): Always invoke resource compiler on windows, fixes #8164 * move all the stuff out of the version check * check for icon path when setting the icon
1 parent 01a7a98 commit a547971

2 files changed

Lines changed: 45 additions & 37 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri-build": 'patch:bug'
3+
---
4+
5+
Fixed an issue that caused the resource compiler to not run on Windows when `package.version` was not set in `tauri.conf.json` preventing the app from starting.

core/tauri-build/src/lib.rs

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -534,47 +534,50 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
534534
.window_icon_path
535535
.unwrap_or_else(|| find_icon(&config, |i| i.ends_with(".ico"), "icons/icon.ico"));
536536

537-
if target_triple.contains("windows") {
538-
if window_icon_path.exists() {
539-
let mut res = WindowsResource::new();
540-
541-
if let Some(manifest) = attributes.windows_attributes.app_manifest {
542-
res.set_manifest(&manifest);
543-
} else {
544-
res.set_manifest(include_str!("window-app-manifest.xml"));
545-
}
537+
let mut res = WindowsResource::new();
546538

547-
if let Some(version_str) = &config.package.version {
548-
if let Ok(v) = Version::parse(version_str) {
549-
let version = v.major << 48 | v.minor << 32 | v.patch << 16;
550-
res.set_version_info(VersionInfo::FILEVERSION, version);
551-
res.set_version_info(VersionInfo::PRODUCTVERSION, version);
552-
}
553-
if let Some(product_name) = &config.package.product_name {
554-
res.set("ProductName", product_name);
555-
}
556-
if let Some(short_description) = &config.tauri.bundle.short_description {
557-
res.set("FileDescription", short_description);
558-
}
559-
if let Some(copyright) = &config.tauri.bundle.copyright {
560-
res.set("LegalCopyright", copyright);
561-
}
562-
res.set_icon_with_id(&window_icon_path.display().to_string(), "32512");
563-
res.compile().with_context(|| {
564-
format!(
565-
"failed to compile `{}` into a Windows Resource file during tauri-build",
566-
window_icon_path.display()
567-
)
568-
})?;
569-
}
570-
} else {
571-
return Err(anyhow!(format!(
572-
"`{}` not found; required for generating a Windows Resource file during tauri-build",
573-
window_icon_path.display()
574-
)));
539+
if let Some(manifest) = attributes.windows_attributes.app_manifest {
540+
res.set_manifest(&manifest);
541+
} else {
542+
res.set_manifest(include_str!("window-app-manifest.xml"));
543+
}
544+
545+
if let Some(version_str) = &config.package.version {
546+
if let Ok(v) = Version::parse(version_str) {
547+
let version = v.major << 48 | v.minor << 32 | v.patch << 16;
548+
res.set_version_info(VersionInfo::FILEVERSION, version);
549+
res.set_version_info(VersionInfo::PRODUCTVERSION, version);
575550
}
576551
}
577552

553+
if let Some(product_name) = &config.package.product_name {
554+
res.set("ProductName", product_name);
555+
}
556+
557+
if let Some(short_description) = &config.tauri.bundle.short_description {
558+
res.set("FileDescription", short_description);
559+
}
560+
561+
if let Some(copyright) = &config.tauri.bundle.copyright {
562+
res.set("LegalCopyright", copyright);
563+
}
564+
565+
if window_icon_path.exists() {
566+
res.set_icon_with_id(&window_icon_path.display().to_string(), "32512");
567+
} else {
568+
return Err(anyhow!(format!(
569+
"`{}` not found; required for generating a Windows Resource file during tauri-build",
570+
window_icon_path.display()
571+
)));
572+
}
573+
574+
res.compile().with_context(|| {
575+
format!(
576+
"failed to compile `{}` into a Windows Resource file during tauri-build",
577+
window_icon_path.display()
578+
)
579+
})?;
580+
578581
let target_env = std::env::var("CARGO_CFG_TARGET_ENV").unwrap();
579582
match target_env.as_str() {
580583
"gnu" => {

0 commit comments

Comments
 (0)