Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I embed version information into a windows binary?

You probably know that Windows has that option where you can view the properties of a binary and it will display information about the author, the version number, the company etc... We would like to put this into our automated compilation system. Getting this version information into the binary after the binary is compiled is preferable, but any information on how this is done would be helpful. And of course, this needs to be programmatic; we can't be bothered to manually enter the information into a resource hacker for 5000 binaries every day.

Has anyone ever done this before? How could it be done?

like image 901
rpetti Avatar asked Jun 10 '09 14:06

rpetti


2 Answers

It looks as though the best solution (for us at least) is to use an RC file.

1 VERSIONINFO
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904E4"
        BEGIN
            VALUE "File Version",      "1.0.4"
            VALUE "Build Number",     "3452"
        END
    END
END

Which is compiled into a .res file

rc.exe /fo Results/version.res version.rc

Which is then linked in with the rest of the object files.

like image 165
rpetti Avatar answered Sep 27 '22 22:09

rpetti


Look for an AssemblyInfo.cs to your project.

But this it has to be filled out before compilation. But you can share one AssemblyInfo.cs between many binaries. And you are not bound to this exact filename - so you can split the information into more files ... one general file about the company, one about the product, one for the binary's version number.

/ Individual Information
[assembly: AssemblyTitle( "" )]
[assembly: AssemblyDescription( "" )]

// Version information
[assembly: AssemblyVersion( "1.0.*" )]
[assembly: AssemblyInformationalVersion( "1.0.0.0" )]

// General Information
[assembly: AssemblyConfiguration( "" )]
[assembly: AssemblyCompany( "" )]
[assembly: AssemblyProduct( "" )]
[assembly: AssemblyCopyright( "" )]
[assembly: AssemblyTrademark( "" )]
[assembly: AssemblyCulture( "" )]
[assembly: NeutralResourcesLanguage( "en" )]
like image 28
tanascius Avatar answered Sep 27 '22 22:09

tanascius