Friday, May 18, 2007

Reducing the size of ccnet.config

[Update 5/19/09: The latest version of CCNet makes this much easier by using a Configuration Preprocessor. I have a short writeup here.]

My demo setup only contains two projects, and there are already a few items that have been duplicated. Items such as paths to SourceSafe and MSBuild executables. As you add more projects, you find yourself copying and pasting lots of info. This isn't recommended when writing code, so why should a config be any different?

Let's take a look at the sourcecontrol blocks. First, my still-empty custom tasks project


<sourcecontrol type="vss" autoGetSource="true">
<ssdir>c:\vss</ssdir>
<executable>C:\Program Files\Microsoft Visual SourceSafe\ss.exe</executable>
<project>$/MSBuild.Chainsaw.Tasks</project>
<workingDirectory>MSBuild.Chainsaw.Tasks</workingDirectory>
</sourcecontrol>

Then the MSBuild Community Tasks


<sourcecontrol type="vss" autoGetSource="true">
<ssdir>c:\vss</ssdir>
<executable>C:\Program Files\Microsoft Visual SourceSafe\ss.exe</executable>
<project>$/MSBuild.Community.Tasks</project>
<workingDirectory>MSBuild.Community.Tasks</workingDirectory>
</sourcecontrol>

Both <ssdir> and <executable> are identical. To simplify things, add the following to the top of the config (above the opening <cruisecontrol>)


<!DOCTYPE cruisecontrol [
<!ENTITY ssCommon
"
<ssdir>c:\vss</ssdir>
<executable>C:\Program Files\Microsoft Visual SourceSafe\ss.exe</executable>

">
]>

Now, those sections can be replaced with "&ssCommon;", like so


<sourcecontrol type="vss" autoGetSource="true">
&ssCommon;
<project>$/MSBuild.Chainsaw.Tasks</project>
<workingDirectory>MSBuild.Chainsaw.Tasks</workingDirectory>
</sourcecontrol>

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.