Search code examples
.netversion-controlassembliesversioningclearcase

Tracking File-level Versioning in builds using Visual Studio and .NET?


I want a tool or a technique to be able to answer the question "What version of file X was used to build Assembly abc.dll?" I recently moved to a .NET development group, and it seems like this question comes up all the time, in one form or another, and we don't quite have a handle on it. Someone will say something like "Hey, is your latest code on the test server?" and the answer is inevitably something like "I don't know".

Back in the old days of Unix development (I'm dating myself here), the SCCS source control system had special keywords such as %I% (version) and %M% (module name) that you could place in your file, that would be replaced with the appropriate SCCS version information whenever the file was checked out. So a neat trick you could do was assign a constant string to "%I% %M%" in your source file, compile, and then run the Unix "strings" command on your resulting library to determine what versions of what files were used to build that file.

I did a quick test to roll-my-own in a C# class file, like this:

public const String VERSION_STRING = "*VERSION* = MyClass 1.0";

Then ran this command line on my DLL directory:

>for %f in (*.dll) do find "VERSION" %f

But the results were:

---------- MYASSEMBLY.DLL
VERSION_STRING

Which is not quite what I was after (it gave me the name of the constant, but none of the version info I had tried to manually embed in the class).

For what it's worth, we're currently using Clearcase for our version control (currently the company standard). Clearcase has some tools that may be able to help us here (such as clearaudit), but that would require some effort towards refinement and retooling of our build process. I should also mention we're considering piloting a switch to subversion. So I guess solutions that work with .NET in any of various version control systems or build environments (MSBuild, NAnt, CruiseControl) are fair game.

Are there any other, particularly .NET-centric, solutions out there, for tracking what version of what file went into what assembly?


Solution

  • We quickly abandoned the idea of using special keywords, since integrated meta-data (like version number) into data (the files stored in the VCS) is generally not a very good idea (see the debate in this SO question: "Embedded Version Numbers - Good or Evil?" )

    Our approach is to build a "release note" with that kind of information. This simple text file is then stored alongside the build dll.