| Tip: Use CC.NET Prebuild to Run Subversion Cleanup Before Building |
| Friday, December 05 2008 |
|
If you've used TortoiseSVN for any length of time, you've no doubt encountered a situation where it tells you to run the Subversion "cleanup" command. This happens when TortoiseSVN needs to clear inconsistencies in your local copy, which means that under-the-covers it needs to re-execute log files within your .svn folders to get things back to a happy state. And usually when this happens, it's easy enough to simply right-click on the offending folder, go to TortoiseSVN, select Cleanup, and you're good to go.
But what if this happens on your build server while running your automated builds? It doesn't make much sense to log on to your build server every time this happens just to manually issue the cleanup command to get the build working again.
To solve this problem, add a <prebuild> element to all of your CC.NET config scripts that issues the cleanup command automatically. The existence of a <prebuild> element in CC.NET means that whatever tasks are inside it are guaranteed to run before anything else in the build script. For example, here's what the <prebuild> element looks like in our Community Server CC.NET build script:
| <prebuild> <exec> <executable>C:\Program Files\CollabNet Subversion\svn.exe</executable> <buildArgs>cleanup</buildArgs> <baseDirectory>D:\Builds\CommunityServer\Working\Trunk</baseDirectory> </exec> </prebuild> |
Having a <prebuild> element in your CC.NET scripts ensures a smooth build each and every time without the need for ad-hoc manual intervention. And the less manual effort, the better.

1 comment(s) so far
Dave,
This rocks, i am going to add this to my build scripts as it makes 100% sense to use.