代码改变世界

Advanced daily build - Auto update build number and lable the source code and bin output

2004-07-29 09:03  atempcode  阅读(1914)  评论(1编辑  收藏  举报

Several days ago, coolbug posted a useful ducument about the daily build. Very instructive. But it missed some important points IMO.

For the daily build, I need:

1. The build number should be increased automaticly.

2. If QA or customer report a bug on a specfic version, I should find the source code, binary outpur and pdb file for that version quickly.

So the idea procedure should be:

1. daily build system check out the source code from server.

2. daily build system automatically inceased the build number according to some rules I set.

3. daily build system do the build.

4. If build successfully, daily build system check in version information files it changed and the build output(exe, dll and pdb).

5. daily build system label the whole code tree inculding the source code and output.

6. [nice to have] daily build system publish the build information to project web. The information should have the build output, build number, links to build output.

Let's try to find the solution.

For the auto-increcement of build number, I found the <version> task in the NANTContrib. It can generate the build number according to some rules.

<version startDate="7-21-2004" buildtype="monthday" revisiontype="automatic" />

This will generate the new version with the build number as (month of today - month of start date)* 100 + today's date, and the revision number as the number of seconds since the start of today.

Our company's version policy does has some difference definition of the four parts of the version number. so i make some change to the versiontask.cs to fit my need.

I also need the version number to be in the final output. After google, I found that the author of the version task has do some work to make this happen. In Ant, there is the filter feature. John ported it to NANT.

In my last blog entry, I introduced the way to manage the centralized version info. I can create a abc.ver.txt with the content

#define VER_FILEVERSION @NumVersion@
#define VER_COMPANYNAME_STR "XYZ Ltd."
#define VER_FILEDESCRIPTION_STR "ABC\0"
#define VER_FILEVERSION_STR "@Version@\0"
#define VER_LEGALCOPYRIGHT_STR "Copyright (C) 2004 XYZ Ltd. "
#define VER_PRODUCTNAME_STR "XYZ's ABC "

We will replace the @NumVersion@ and @Version@ with the actual version number in the following task:

<filter token="Version" value="${sys.version}" />
<filter token="NumVersion" value="${sys.verForRc}" />
<copy file="abc.ver.txt" tofile="abc.ver" filtered="true" />

The ${sys.version}is the version number generated in the version task in x.x.x.x format. The "NumVersion" is the version number in x,x,x,x format. When copy from the abc.ver.txt to abc.ver, the filter will replace the @xx@ with the filter value.

John made changes to an old version of NANT, I have merge the changes to the 0.84 of NANT. I never do C# programming before, but it is so easy to learn that after 10 minutes of coding, the NANT compiled with my change. Here are the added and modified file.

Next is to check in and label everything. It is relatively easy.

Maybe I will talk about the publishing to web in another blog entry.