Archive for June, 2008

Updating Your Web.Config From Each Build with CruiseControl

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.

Regular Expression Designer

If you are doing frequent work with regular expressions, check out this free tool – Regular Expression Designer by Rad Tools.  It’s very nice and helps you with debugging those pesky statements with different input.

And just 2 reminders regarding naming of variables:

1. Short acronyms should be uppercase
http://msdn.microsoft.com/en-us/library/ms182256(VS.80).aspx

2. Identifiers should be cased correctly
 
http://msdn.microsoft.com/en-us/library/ms182240(VS.80).aspx

Hopefully I’ll post some more stuff soon, been busy last week with personal stuff (selling my car, etc.)

Optimization WordPress Plugins & Solutions by W3 EDGE