Let’s say you have CruiseControl.NET all set up nice and hunky dory.  Now you love the fact that it labels your each build, and you want to somehow show that from your project.  Here is how you can get your CruiseControl.NET project build number into your Web.Config.  This concept can be applied to update any file.
It’s super easy. You will need to add an exec block to your ccnet.config
<exec>
<!-- Auto increment web.config build number -->
<executable>E:\Userdata\CruiseControl\Tools\MergeWebConfigValues.exe (my custom tool)</executable>
<buildArgs>"E:\Program Files (x86)\CruiseControl.NET\server\Main.state" e:\userdata\cruisecontrol\Dev_Main\Web.config</buildArgs>
<baseDirectory>e:\userdata\cruisecontrol\Dev_Main</baseDirectory>
<buildTimeoutSeconds>15</buildTimeoutSeconds>
</exec>
 Now all you need to do is write the MergeWebConfigValues.exe
What does it do?
1. It reads the CCNET state file (provided by argument 1) and grabs the last label from there. (The state file is an XML file)
2. It then goes and writes to your Web.Config and updates the build number in there. (or writes to any specified file you like)
Lastly, update your code to read this value by adding some version or about page to read your Web.Config
You now instantly know what version your code is.

Other Interesting Posts

 

Leave a Reply

Your email address will not be published. Required fields are marked *

*


7 + 6 =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>