views:

378

answers:

3

Hi,

I am updating the code on a daily basis and commit all changes in each case so there is the new code available on server all the time.

What I would like to simplify is build automation and version control. Currently I build a project and edit it's name version (Project Name vx.x.x) each time the the boss needs it which is not time effective.

Does anyone know what's the best way to keep the newest software version with corresponding version number available all the time?

For development I use VS 2008 and for subversioning Tortoise SVN. I tried to use nant for buid automation but don't have any experience with it and don't know how could I edit version number in VS or pass the Tortoise's revison number to nant so it could generate project name with release number.

Thanks!

A: 

I'm in the process of automating this myself. Still exploring options, but this seems to be simple and reliable:

  • Create a "utility" project called "_FULL_BUILD_" within the global VC 6.0 workspace.

  • _FULL_BUILD_ has no files of its own, but it depends on all other projects, ensuring they all get (re)built appropriately.

  • One early dependency is another utility project that uses sed.exe from http://sourceforge.net/projects/unxutils to increment the version, which is stored in its own file, as necessary:

    • For debug builds, just increment the build number.
    • For release builds, increment the last portion of the version number.
    • Major / minor releases require manual editing.

The "magic" was the empty utility project, which also allows you to create custom build rules that (for example) might copy the complete project to a drop point for your QA team.

Please let us know if you find a better solution.

Good luck!

Adam Liss
+2  A: 

Using subversions version number is not optimal. I tried that once, but it fails because the changeset number is only related to the files that are changed in that particular changeset.

Anyway, I would recommend using CruiseControl for this as it is capable of keeping track of the build number separate from subversion. CC passes some properties to the build script, amongs them is the build label, called "${label}". Use that in your nant script.

Invest the time to learn (n)ant and CC.

Martin Wickman
+3  A: 

First, don't try to use SVN keyword substitution to do this. If you put the $rev$ keyword inside a file and enable keyword substitution with the svn:keywords property, you will not get what you want. You will get the last revision that affected the file that contains the keyword, instead of the last revision that affected any part of the project.

The correct way to do this is to use the output of the svnversion command. You will probably need to write a little script that invokes this command, captures the output and then uses the revision number to update a project file or source code file somewhere.

If you can rely on TortoiseSVN being installed, an easier alternative is to use the SubWCRev.exe utility like this:

SubWCRev.exe . VersionInfo.template VersionInfo.cs

where VersionInfo.template would look like this for a C# project:

using System.Reflection;

[assembly: AssemblyVersion("2.0.0.$WCREV$")]
[assembly: AssemblyFileVersion("2.0.0.$WCREV$")]

Caveat: windows version numbers consist of 4 numbers, each limited to 16 bit. Subversion revision numbers can easily become bigger than that.

Wim Coenen