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
This commit is contained in:
Fabian-Lars 2023-11-06 20:46:25 +01:00 committed by GitHub
parent 01a7a983ab
commit a547971209
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 36 deletions

View File

@ -0,0 +1,5 @@
---
"tauri-build": 'patch:bug'
---
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.

View File

@ -534,8 +534,6 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
.window_icon_path
.unwrap_or_else(|| find_icon(&config, |i| i.ends_with(".ico"), "icons/icon.ico"));
if target_triple.contains("windows") {
if window_icon_path.exists() {
let mut res = WindowsResource::new();
if let Some(manifest) = attributes.windows_attributes.app_manifest {
@ -550,30 +548,35 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
res.set_version_info(VersionInfo::FILEVERSION, version);
res.set_version_info(VersionInfo::PRODUCTVERSION, version);
}
}
if let Some(product_name) = &config.package.product_name {
res.set("ProductName", product_name);
}
if let Some(short_description) = &config.tauri.bundle.short_description {
res.set("FileDescription", short_description);
}
if let Some(copyright) = &config.tauri.bundle.copyright {
res.set("LegalCopyright", copyright);
}
if window_icon_path.exists() {
res.set_icon_with_id(&window_icon_path.display().to_string(), "32512");
res.compile().with_context(|| {
format!(
"failed to compile `{}` into a Windows Resource file during tauri-build",
window_icon_path.display()
)
})?;
}
} else {
return Err(anyhow!(format!(
"`{}` not found; required for generating a Windows Resource file during tauri-build",
window_icon_path.display()
)));
}
}
res.compile().with_context(|| {
format!(
"failed to compile `{}` into a Windows Resource file during tauri-build",
window_icon_path.display()
)
})?;
let target_env = std::env::var("CARGO_CFG_TARGET_ENV").unwrap();
match target_env.as_str() {