Tuesday, July 03, 2007 8:46 PM
I am a huge fan of Continuous Integration and have been using CruiseControl.NET (CCNet) successfully for the past year. Recently, I've run across a limitation in the way the cnet.config file is used. Normally, when a developer needs to reuse some piece of information, such as a file path, he will put this information in a Property or Constant. However, unlike MSBuild files which supports a PropertyGroup, the ccnet.config provides no support for Properties or Constants.
For example, in my ccnet.config file, I need to specify the artifactDirectory, where build artifacts will be stored.
<artifactDirectory>C:\Projects\Artifacts\MyFirstProject</artifactDirectory>
Let's say I have 10 projects to build. I will need to copy and paste the path above 9 more times. This "copy and paste" mentality introduces too many places for error for my taste. So, after searching the net for a while, I finally found a solution. Enter the XML Entity.
So, now, we can do the following.
Enter this at the top of the ccnet.config file:
<!DOCTYPE cruisecontrol[
<!ENTITY ArtifactsDirectory "C:\Projects\Artifacts">
]>
Use the XML Entity in place of the hard coded string:
<artifactDirectory>&ArtifactsDirectory;\MyFirstProject</artifactDirectory>
<artifactDirectory>&ArtifactsDirectory;\MySecondProject</artifactDirectory>
etc...