3

Project in Delphi 2007, stored in SVN.

"Project settings - version info" - there the project version is stored. When changing the project version *.dproj file and *.res file are changing. And I have to commit them to SVN every time when project version changes.

I want to manage project version with SVN. For example, when building the project from svn tag named "1.12.2" and revision 12993 I want to get a binary *.exe file with version 1.12.2.12993.

To make it, I should create a *.rc file with text presentation of version info. Then make a *.res file and include it to project with {$R version.res}

What shold I write to *.rc file? What should it's structure look like? White an example, please.

Thanks.

Mikhail Kopylov
  • 2,008
  • 5
  • 27
  • 58
  • Just google for MSDN versioninfo structure. Plenty of information there. The first page gives: http://pisoft.ru/verstak/insider/cw_ver1.htm showing exactly what you are asking for. Googling for MSDN Versioninfo resource turns up the link in David's answer. – Marjan Venema Oct 16 '12 at 17:16

3 Answers3

5

The VERSIONINFO resource is documented on MSDN. A typical such resource script looks like this:

1 VERSIONINFO
FILEVERSION 1,12,2,12993
PRODUCTVERSION 1,12,2,12993
FILEOS 0x40004L
FILETYPE 0x1L
BEGIN
  BLOCK "StringFileInfo"
  BEGIN
    BLOCK "000004E4"
      BEGIN
        VALUE "CompanyName", "My Company\0"
        VALUE "FileDescription", "My Program\0"
        VALUE "FileVersion", "My Program\0"
        VALUE "LegalCopyright", "My Company 2012\0"
      END
  END
  BLOCK "VarFileInfo"
  BEGIN
    VALUE "Translation", 0x0000 0x04E4
  END
END
David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • It's perfect! That's what I need. – Mikhail Kopylov Oct 16 '12 at 17:34
  • 1
    I have small quesion in this, we have to change FILEVERSION and PRODUCTVERSION manually each time? how we can change it automatically? is there way? – Nalu Oct 16 '12 at 20:58
  • @Naren Write a script to generate or modify the resource script automatically. For example it could be a simple Perl or Python script. That's how I do it. – David Heffernan Oct 16 '12 at 21:35
  • @David: Yes. Thinking in same way but want to make sure. Thanks for answer. – Nalu Oct 16 '12 at 21:45
  • There's an answer to a [version related question here](http://stackoverflow.com/a/11782584/62576) that provides the VERSIONINFO definition including specific use instructions. In the comments to that answer, there's a link to a utility application (including Delphi source) that will handle updating the version for you automatically each build. – Ken White Oct 16 '12 at 21:59
2

Here's how we do it:

We have a dedicated build machine that builds our "official" binaries, then checks them into svn. The binary, along with the .res and .bdsproj, are then checked into svn using special comment tags [Add Project File][Add Res File].

Developers are instructed to NOT checkin .bdsproj and .res files unless functional changes have been made, in which case they need to use the special tags.

SVN uses a pre-commit hook to block .res and .bdsproj checkins without the special tags.

When we create a new project branch, we have a utility (I think it's FindAndReplace.exe) that updates all of the version info in the .bdsproj files to match.

This is NOT exactly what you're looking for, because we're not incorporating the SVN build as part of this. But that could be done, as an extension of this methodology.

Chris Thornton
  • 15,620
  • 5
  • 37
  • 62
2

We use VERSIONINFO as well, but instead of build number we use SVN revision number, which can be supplied by keyword substitution using SubWCRev utility. see Tortoise dox for details. It allows you to get right source snapshot from SVN corresponding to particular .exe

pf1957
  • 997
  • 1
  • 5
  • 20