Skip to content

feat: embed Windows VERSIONINFO in tgrep.exe#85

Merged
shengyfu merged 3 commits into
mainfrom
feat/add-windows-version-info
Jun 12, 2026
Merged

feat: embed Windows VERSIONINFO in tgrep.exe#85
shengyfu merged 3 commits into
mainfrom
feat/add-windows-version-info

Conversation

@msftsiwei

@msftsiwei msftsiwei commented Jun 12, 2026

Copy link
Copy Markdown
Member

Summary

Add Windows VERSIONINFO resource embedding so that signed grep.exe shows ProductName, FileVersion, CompanyName, etc. in the Windows "Properties → Details" tab.

Problem

After OneBranch signing, grep.exe has a valid Authenticode signature but no product metadata (ProductName, FileVersion, etc. are all blank). This is because Rust binaries don't include Windows VERSIONINFO resources by default.

Solution

  • Add winresource as a Windows-only build dependency in grep-cli/Cargo.toml
  • Create grep-cli/build.rs to embed VERSIONINFO with:
    • ProductName: tgrep
    • FileDescription: tgrep - trigram-indexed grep for large codebases
    • CompanyName: Microsoft Corporation
    • LegalCopyright: Copyright (c) Microsoft Corporation. All rights reserved.
    • InternalName: tgrep
    • OriginalFilename: tgrep.exe
    • FileVersion / ProductVersion: auto-populated from Cargo.toml

Reference

Same pattern used by other Microsoft Rust projects:

All three use OneBranch + onebranch.pipeline.signing@1 with external_distribution profile — same as tgrep.

Changes

  • grep-cli/Cargo.toml: add [target.'cfg(windows)'.build-dependencies] winresource = "0.1"
  • grep-cli/build.rs: new file, embeds VERSIONINFO on Windows builds

Testing

  • No pipeline changes needed — VERSIONINFO is embedded at compile time
  • OneBranch signing signs the final binary which already contains the resource
  • Verify after next OneBranch build: right-click tgrep.exe → Properties → Details

Copilot AI review requested due to automatic review settings June 12, 2026 02:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a Windows build-time resource step so the produced (and later OneBranch-signed) tgrep.exe includes standard VERSIONINFO metadata (ProductName, FileVersion, CompanyName, etc.) visible in Windows Explorer “Properties → Details”.

Changes:

  • Add winresource as a Windows-only build dependency for tgrep-cli.
  • Introduce a tgrep-cli/build.rs build script that compiles VERSIONINFO into the Windows binary.
Show a summary per file
File Description
tgrep-cli/Cargo.toml Adds Windows-only winresource build dependency to enable resource embedding.
tgrep-cli/build.rs New build script that sets VERSIONINFO fields and compiles them into tgrep.exe.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 1

Comment thread tgrep-cli/build.rs
Add winresource build dependency and build.rs to embed ProductName,
FileDescription, CompanyName, LegalCopyright, InternalName, and
OriginalFilename into the Windows binary. FileVersion and ProductVersion
are auto-populated from Cargo.toml.

Without this, the signed binary shows no product metadata in
Windows Properties > Details tab.

Reference implementations:
- microsoft/vscode cli/build.rs
- microsoft/coreutils build.rs
- microsoft/python-environment-tools crates/pet/build.rs

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@msftsiwei msftsiwei force-pushed the feat/add-windows-version-info branch from 2763828 to b041633 Compare June 12, 2026 02:45
Move winresource to unconditional build-dependencies so build.rs can compile on non-Windows hosts while still gating resource generation by target OS. Update Cargo.lock for --locked release builds.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 12, 2026 15:57
@shengyfu shengyfu enabled auto-merge (squash) June 12, 2026 16:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 2/3 changed files
  • Comments generated: 2

Comment thread tgrep-cli/build.rs Outdated
Comment thread tgrep-cli/Cargo.toml
Keep winresource as a Windows-host build dependency and compile the resource embedding code only on Windows hosts. Non-Windows hosts targeting Windows now emit a Cargo warning instead of failing when no resource compiler is available.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@shengyfu shengyfu merged commit 653acb2 into main Jun 12, 2026
9 checks passed
@shengyfu shengyfu deleted the feat/add-windows-version-info branch June 12, 2026 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants