From 9028432e8a71b9601ff65160a29e683a9cc24989 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Wed, 30 Sep 2026 09:20:58 +0200 Subject: [PATCH] fix: embed a VERSIONINFO resource in the Windows binary (#11433) Co-authored-by: Claude Opus 5.5 (1M context) --- backend/Cargo.lock | 10 ++++++++++ backend/Cargo.toml | 3 +++ backend/build.rs | 15 +++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/backend/Cargo.lock b/backend/Cargo.lock index c1cdb2326c..114fb76b67 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -14876,6 +14876,7 @@ dependencies = [ "windmill-worker-volumes", "windows-service", "windows-sys 0.52.0", + "winresource", ] [[package]] @@ -17382,6 +17383,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "winresource" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0986a8b1d586b7d3e4fe3d9ea39fb451ae22869dcea4aa109d287a374d866087" +dependencies = [ + "version_check", +] + [[package]] name = "winsafe" version = "0.0.19" diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 5970ada6d8..9c09265dbd 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -329,6 +329,9 @@ strum.workspace = true windows-service = "0.7" windows-sys = { version = "0.52", features = ["Win32_System_Services", "Win32_System_Console", "Win32_Foundation"] } +[target.'cfg(windows)'.build-dependencies] +winresource = { version = "0.1.31", default-features = false } + [target.'cfg(not(target_env = "msvc"))'.dependencies] tikv-jemallocator = { optional = true, workspace = true } tikv-jemalloc-sys = { optional = true, workspace = true } diff --git a/backend/build.rs b/backend/build.rs index d5068697c7..88917b0492 100644 --- a/backend/build.rs +++ b/backend/build.rs @@ -2,4 +2,19 @@ fn main() { // trigger recompilation when a new migration is added println!("cargo:rerun-if-changed=migrations"); + + // Embed a VERSIONINFO resource so the exe's file properties carry the release + // version (from Cargo.toml), which Windows worker update scripts read. + // `cfg(windows)` is the host, matching the Windows-only build-dependency, so + // cross builds to Windows get no version resource. + #[cfg(windows)] + if std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("windows") { + winresource::WindowsResource::new() + .set("ProductName", "Windmill") + .set("FileDescription", "Windmill") + .set("CompanyName", "Windmill Labs, Inc.") + .set("LegalCopyright", "Copyright Windmill Labs, Inc.") + .compile() + .expect("failed to embed the Windows version resource"); + } }