Version stamp with resource file

Version stamp with resource file

Colleagues,

I need to begin stamping dates and version numbers into .exe files produced from our Fortran source.  I understand this is done with a resource file -- which in this case is just text file - that are in the resource fold in VS. Is there a template/standard/sample for this? I'm in VS 2015.

David

7 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Found it.  Sorry to bother with the posting.

D

Hi David, tell us what you found  to answer your question.

Here's what I found:

  1. Right click on the the Resource Files folder in the Solution Explorer side-bar in a Visual Studio solution.
  2. Click Add, New Item, then "Resource File (.rc)" from the list. Then click Add
  3. A resource file is created in the Resource Folder. Double-clicking on the file opens it in the Resource Editor in a new tab in the open files list in VS.
  4. By default, the resource file contains a string table.
  5. Right click on the file in the resource editor and click on Add Resource from the drop-down
  6. From the list window, choose Version, then click New
  7. A standard list of "Keys" and "Values" appears. The values can be modified as required, including version number, etc. This list of keys is in its own tab in the resource editor. After modification, the list (tab) can be dismissed.
  8. I removed the string table by opening it, right clicking on "String Table" and choosing delete. This leaves only the version info in the resource file.
  9. Multiple resource files can be created, each associated with different type of builds from the same code; debug, release, chip-specific, etc.
  10. Once the resource file(s) are built they need only have their content changed before compiling and linking to have the resulting .exe stamped with the require information.
  11. There is no way to automatically update the version number in the resource file (at least not in VS 2015 -  I don't know about VS 2017)
    1. An external process can be used to modify the resource file with the version info. It's a text file with a fixed format.
    2. The process needs to be run as a Pre-Build Event, changing the text values in the resouce file before it (and the rest of the code) is compiled and linked.

 

I know this is not part of what you are doing, but I seem to remember a post from several years back where the version information from the resource file was being used in the Fortran source itself.  My main trouble with the resource file I have is that I have "types" of the same application, and the Fortran itself needs the version information as does the resource.  Hence every time I manually update the version I am doing it in several places: 1) the resource file; 2) version.h which is part of the resources; 3) a local Fortran module, call it VERSION.  Multiply this by the number of projects in the solution (for me this is two), and I am always running the risk of version information being out of sync.

Right.  I have the same difficulty. After I worked through all this, I could see that there would a large number of (perhaps) identical resource files sitting around.  Our complete system consists of several .exe files, each with their own VS solution file.  Though they all share the same major (and perhaps minor) version number, they each will very likely have different build numbers (last digit in the complete version number), since bugs and fixes appear in different places at different times.

A suggestion I found on the net was to have a single file hold the major and minor version numbers and have build numbers change 'locally'. This appears to require a separate Pre-Build activity depending on (in your case) the "type" of the same application. The Pre-Build program/script/app would consult the single file hold major and minor version numbers and the appropriate local resource file (for the last build number) and increment accordingly. I haven't convinced myself (yet) that this is the best solution.

In my prebuild step, I use a program that I wrote which directly edits the resource file.  This finds the FILEVERSION entry and updates it.

Leave a Comment

Please sign in to add a comment. Not a member? Join today