views:

917

answers:

3

I am able to get cruisecontrol working with svn. What I am trying to do is that when cruisecontrol detects a change in the repository then it deletes everything inside my working directory and then checks out the entire project again. I am not sure how I can do that. Seems like cruisecontrol automatically updates the working directory when there is and update in the repository ,but it doesn't remove extra files(like bin file) before it updates the directory.

Thanks

A: 

I don't know if SVN works in a similar fashion like TFS (it has a cache and so on ... ), but here is how I do this with CC.NET and Sourcesafe:

In the prebuild section of my project, I make sure that I clean my working directory, that is: I delete everything that is inside it.
(The tasks that are included in the prebuild section, will be executed before CC.NET will get the latest version of your project out of source-control).

To accomplish this, I call a Target that is defined in my buildscript (msbuild) which is called 'clean'.

This target removes all files and directories.

This is more or less how the task in my msbuild buildscript looks like (by heart, I don't have it right here with me):

<Task name="clean">
   <ItemGroup>
       <FilesToDelete include="$(workingdir)\**\*.*" />
   </ItemGroup>
   <ItemGroup>
        <DirectoriesToDelete include="$(workingdir)\**" />
   </ItemGroup>
   <Delete Files="@(FilesToDelete)" />
   <RemoveDir Directories="@(DirectoriesToDelete)" />
</Task>

Then, in the CC.NET project configuration, I call the MSBuild script using the MSBuild task, and i call this target.

What I like about this, is that I can clean my working directory on my workstation very easily as well; I just have to call this target using a call to msbuild on the commandline, and my working dir is empty. I've similar tasks to perform a getlatest, complete build, etc... as well.

Frederik Gheysels
+2  A: 

In your ccnet.config file does your source control block contain the cleanCopy item? To delete everything in the working directory make sure cleanCopy is set to "true"

Hope this helps.

Chris Mitchell
I don't know for some reason I can't get cleanCopy to work with svn.I am using multi sourcecontrols for svn.
A: 

You could have your build script delete the bin directory first, then compile the project. Create a build task called "clean" that deletes the compiled output folder, then set the task "mainBuild" to depend on "clean". It's easier to create the "clean" task if everything compiles to a common output folder.

Whether you set ccnet.config to clean your working copy, or add a build task to clean your working copy is a matter of preference.

mcdon