Incrementing Workspace Build Versions

Environment: VC6


The problem...

I develop several multi-project applications and have always had trouble keeping up with all my changes.

Typically, I create several "release" builds while I am developing, so I can test as I go. Then I create a complete build of all modules for my clients. This is the only time I really care to increment the build number.

In the past I have created a separate resource file with my build number (similar to the Microsoft solution in the MSDN library). But whenever the resource file changes, visual studio doesn't keep the changes to the .RC file.


So enter a better solution(?)...

This simple program will ready your workspace files and check all the projects it contains. Each project is checked for changes, since the last time it was run. If a project changes, then anything dependent on it will also be changed.

The picture above shows a workspace with 2 projects (Play1 & Play2). Play1 is dependent on Project2. One file changed (see the '**' by Play2.cpp) in Pay2 (see the '**' by Play2.dsp), so the build number was incremented for Play1 and Play2 (see the '**' by both projects).


How it works...

When versions are incremented, a file is added with the name of the project file and the extension of "absVersion". This file contains the last build number used and is dated with the date of the last build (this is used to check for changes).


Script segment from the Microsoft Developer Studio generated resource script:
//
// Version
//

VS_VERSION_INFO VERSIONINFO
 FILEVERSION 1,0,0,8 <<--- This will be incremented when 
                              dependencies have changed.
 PRODUCTVERSION 1,0,0,8 <<--- This will be incremented when 
                              dependencies have changed.
 FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
 FILEFLAGS 0x1L
#else
 FILEFLAGS 0x0L
#endif
 FILEOS 0x4L
 FILETYPE 0x1L
 FILESUBTYPE 0x0L
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904b0"
        BEGIN
            VALUE "Comments", "\0"
            VALUE "CompanyName", "Automated Business Soultions, Inc.\0"
            VALUE "FileDescription", "absBuildIncrement MFC Application\0"
            VALUE "FileVersion", "1, 0, 0, 8\0" <<--- This will be 
                     incremented when dependencies have changed.
            VALUE "InternalName", "absBuildIncrement\0"
            VALUE "LegalCopyright", "Copyright (C) 2001\0"
            VALUE "LegalTrademarks", "\0"
            VALUE "OriginalFilename", "absBuildIncrement.EXE\0"
            VALUE "PrivateBuild", "\0"
            VALUE "ProductName", "absBuildIncrement Application\0"
            VALUE "ProductVersion", "1, 0, 0, 8\0" <<--- This will be 
                     incremented when dependencies have changed.
            VALUE "SpecialBuild", "\0"
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x409, 1200
    END
END

Downloads

Download demo project - 12 Kb
Download source - 54 Kb


Comments

  • test

    Posted by Legacy on 08/29/2003 12:00am

    Originally posted by: chang

    test

    Reply
  • A bug in the OnUpdate

    Posted by Legacy on 06/03/2001 12:00am

    Originally posted by: Scot Brennecke

    I like your concept.  However, I'm not sure why your code works for anyone, as there is a significant bug in the OnUpdate function.
    
    On the line where you Format the strVersion CString, you are using the CString itself as input!
    This certainly doesn't work in my environment (I have VC6 SP5 on Win2K).
    You can solve the problem simply by using another temporary CString for the format and subsequent SetAt in the array.

    Also, there's no need for the GetBuffer(0) call -- just use the (LPCTSTR) cast operator to get the string to copy.

    CString strNewVer ;
    strNewVer.Format( "%s,%d", (LPCTSTR)strVersion, iBuild ) ;
    m_saProjectVersions.SetAt( i, strNewVer ) ;
    strVersion = strNewVer ;

    Thanks for the neat utility!


    Reply
  • oh~!!! greatful!

    Posted by Legacy on 06/01/2001 12:00am

    Originally posted by: hahyojin

    oh~~~ Wonderful!
    Very good idea~~~...*^^*

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: October 29, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you interested in building a cognitive application using the power of IBM Watson? Need a platform that provides speed and ease for rapidly deploying this application? Join Chris Madison, Watson Solution Architect, as he walks through the process of building a Watson powered application on IBM Bluemix. Chris will talk about the new Watson Services just released on IBM bluemix, but more importantly he will do a step by step cognitive …

  • On-demand Event Event Date: October 23, 2014 Despite the current "virtualize everything" mentality, there are advantages to utilizing physical hardware for certain tasks. This is especially true for backups. In many cases, it is clearly in an organization's best interest to make use of physical, purpose-built backup appliances rather than relying on virtual backup software (VBA - Virtual Backup Appliances). Join us for this webcast to learn why physical appliances are preferable to virtual backup appliances, …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds