Skip to content

Commit 1ca2dd6

Browse files
authored
fix(tauri-build): properly set executable version info on Windows (#4045)
1 parent 4562e67 commit 1ca2dd6

3 files changed

Lines changed: 13 additions & 1 deletion

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
3+
---
4+
5+
Properly set file version information for the Windows executable.

core/tauri-build/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ serde_json = "1"
2626

2727
[target."cfg(windows)".dependencies]
2828
winres = "0.1"
29+
semver = "1"
2930

3031
[features]
3132
codegen = [ "tauri-codegen", "quote" ]

core/tauri-build/src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
256256
#[cfg(windows)]
257257
{
258258
use anyhow::Context;
259-
use winres::WindowsResource;
259+
use semver::Version;
260+
use winres::{VersionInfo, WindowsResource};
260261

261262
let icon_path_string = attributes
262263
.windows_attributes
@@ -276,6 +277,11 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
276277
}
277278
}
278279
if let Some(version) = &config.package.version {
280+
if let Ok(v) = Version::parse(version) {
281+
let version = v.major << 48 | v.minor << 32 | v.patch << 16;
282+
res.set_version_info(VersionInfo::FILEVERSION, version);
283+
res.set_version_info(VersionInfo::PRODUCTVERSION, version);
284+
}
279285
res.set("FileVersion", version);
280286
res.set("ProductVersion", version);
281287
}

0 commit comments

Comments
 (0)