SharpDeveloper
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)
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.
Related Reading:
Other Interesting Posts
-
Articles
- January 2011
- April 2010
- March 2010
- February 2010
- January 2010
- August 2009
- July 2009
- June 2009
- May 2009
- April 2009
- February 2009
- December 2008
- November 2008
- October 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
-
Meta







