fix(tauri-build): properly set executable version info on Windows (#4045)

This commit is contained in:
Lucas Fernandes Nogueira 2022-05-03 10:04:23 -07:00 committed by GitHub
parent 4562e671e4
commit 1ca2dd677d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 1 deletions

View File

@ -0,0 +1,5 @@
---
"tauri-build": patch
---
Properly set file version information for the Windows executable.

View File

@ -26,6 +26,7 @@ serde_json = "1"
[target."cfg(windows)".dependencies]
winres = "0.1"
semver = "1"
[features]
codegen = [ "tauri-codegen", "quote" ]

View File

@ -256,7 +256,8 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
#[cfg(windows)]
{
use anyhow::Context;
use winres::WindowsResource;
use semver::Version;
use winres::{VersionInfo, WindowsResource};
let icon_path_string = attributes
.windows_attributes
@ -276,6 +277,11 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
}
}
if let Some(version) = &config.package.version {
if let Ok(v) = Version::parse(version) {
let version = v.major << 48 | v.minor << 32 | v.patch << 16;
res.set_version_info(VersionInfo::FILEVERSION, version);
res.set_version_info(VersionInfo::PRODUCTVERSION, version);
}
res.set("FileVersion", version);
res.set("ProductVersion", version);
}