Files
JoyD/Windows/CS/Framework4.0/BootLoader/build.rs
2026-04-28 17:03:01 +08:00

33 lines
1.2 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

use winres::WindowsResource;
fn main() {
// 仅在 Windows 上处理资源文件
#[cfg(windows)]
{
let mut res = WindowsResource::new();
// 编码方式高32位 = (major << 16 | minor)低32位 = (patch << 16 | build)
// 1.0.0.0 => major=1, minor=0, patch=0, build=0 => 0x0001_0000_0000_0000
res.set_version_info(winres::VersionInfo::FILEVERSION, 0x0001_0000_0000_0000);
res.set_version_info(winres::VersionInfo::PRODUCTVERSION, 0x0001_0000_0000_0000);
// 关键:显式设置字符串版本字段,与二进制版本保持一致
// 不设置的话PowerShell/.NET/Explorer 可能从不同字段读取,导致不一致
res.set("FileVersion", "1.0.0.1");
res.set("ProductVersion", "1.0.0.1");
// 设置产品名和公司名
res.set("ProductName", "BootLoader");
res.set("CompanyName", "JoyD");
res.set("FileDescription", "应用程序启动器");
res.set("LegalCopyright", "Copyright JoyD");
if let Err(e) = res.compile() {
eprintln!("Failed to compile resource file: {}", e);
std::process::exit(1);
}
}
println!("cargo:rerun-if-changed=build.rs");
}