views:

804

answers:

4

I use CruiseControl.NET to automatically build my .NET 3.5 web applications, which works a treat. However, is there any way to automatically create a ZIP file of these builds, and put the ZIP's into a separate directory?

I have seen this is possible using NAnt but cannot find an example of how to get this working.

Can anyone offer help/examples?

+1  A: 

If you're using Nant, then doesn't the Zip task work for you?

David Kemp
A: 

We are zipping the sources of a CruiseControl.NET project

but we are using ant

<target name="zipProject">
   <mkdir dir="output"/>
   <zip destfile="output\sources.zip" basedir="C:\project\src" />
</target>

i don't know about nant but i would expect it to be similar

domruf
A: 

@David: The NAnt Zip task is what I'm after, yes, but I'm asking how to integrate it as part of an automatic CruiseControl.NET build. If you take a look at the NAnt documentation for the cruise control config it doesn't make it clear if I can run an NAnt task from inside the XML node in my CruiseControl config - it only says that it can be part of a .

I have found a few examples of setting up your CruiseControl config and a few examples of NAnt tasks but nothing that integrates the two: specifically, zipping up a CruiseControl build.

If anyone has some sample XML of their CruiseControl config, hooking up to an NAnt zip task, post samples here.

Cheers.

Alex York
Whoops it stripped out my XML node example, should say this: "...from inside the < tasks > XML node in my CruiseControl config - it only says that it can be part of a < schedule > ..."
Alex York
The link you want for NAnt task documentation is:http://confluence.public.thoughtworks.org/display/CCNET/NAnt+Task
Pedro
+2  A: 

I've just added such a Nant task to our CC machine.

See http://nant.sourceforge.net/release/latest/help/tasks/zip.html

Note when initially viewing the zip archive, it may appear as if all the files are at the same level, i.e no folders, but actually they folders are preserved.

Notice how you can exclude file types or folders.

You could take the approach of only including the file types you want and excluding the rest.

First define properties for where the source files are allcode.dir and the name and location of the zip file sourcebackup.zip

Now here is the nant task

 <zip zipfile="${sourcebackup.zip}" includeemptydirs="true" verbose="true"> 
 <fileset basedir="${allcode.dir}"> 
      <include name="**/*" /> 
      <exclude name="**/_resharper*/**" /> 
      <exclude name="**/build/**" /> 
      <exclude name="**/obj/**" /> 
      <exclude name="**/bin/**" /> 
      <exclude name="**/*.dll" /> 
      <exclude name="**/*.scc" /> 
      <exclude name="**/*.log" /> 
      <exclude name="**/*.vssscc" /> 
      <exclude name="**/*.suo" /> 
      <exclude name="**/*.user" /> 
      <exclude name="**/*.pdb" /> 
      <exclude name="**/*.cache" /> 
      <exclude name="**/*.vspscc" /> 
      <exclude name="**/*.msi" /> 
      <exclude name="**/*.irs" /> 
      <exclude name="**/*.exe" /> 
 </fileset>

<echo message="########## Zipped##########" />

Call this from your cc build like any other nant task. We find it best if each CC project calls a single task if possible, then you only have to change the nant script, and you can run the nant script on your local machine.

Eg in the project block, we have the single target "build", which as part of its work calls ZipSource

<targetList>
          <target>Build</target>
        </targetList>

We use the above for a BizTalk project.

Enjoy.

bamboowave