Derik Whittaker

Syndication

News


How to copy an entire folder tree with Nant

Ok, so this sounds like it should be drop dead simple and it is, however it is not (at least to me) 100% intuitive how you could accomplish this.

Here is what I wanted to do.  I wanted to be able to copy ALL of my compiled dlls from my build to a ‘staging’ location and I wanted to do this in a simple manor. The first thing I did of course was to jump out to the nant project page to refresh my memory on the <copy> feature.  Sadly after reading the doc, i did not find anything that stuck out and said ‘hey, if you need to copy an entire folder structure do this’.

However, with a bit of googling I was able to figure out a simple way to do it.

  <target name="copy.nightlyBuild.to.staging.location">
    <property name="dir.nightlyBuild.destination" value="C:\NightlyBuilds_Output\Build" />
    <mkdir dir="${dir.nightlyBuild.destination}" if="${not(directory::exists(dir.nightlyBuild.destination))}" />

    <copy todir="${dir.nightlyBuild.destination}" includeemptydirs="true" overwrite="true" verbose="true">
      <fileset basedir=".\SOME_FOLDER_TO_COPY_FROM">
        <include name="**/*.*" />
      </fileset>
    </copy>
    
  </target>

What makes this process work is the **\*.* in the include section.  the **\ tells nant to do a recursive copy.

Hope this helps

Till next time,


Posted 07-07-2009 10:43 AM by Derik Whittaker

[Advertisement]

Comments

Reza wrote re: How to copy an entire folder tree with Nant
on 07-07-2009 3:18 PM

It's not terribly intuitive for a MSBuild script either, although the syntax is exactly the same (using **\*.* I mean).

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Subscribe
Google Reader or Homepage

del.icio.us CodeBetter.com Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl CodeBetter.com Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of Devlicio.us
Red-Gate Tools For SQL and .NET

NDepend

SlickEdit
 
SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
LiteAccounting.Com
DevExpress
Fixx
NHibernate Profiler
Unfuddle
Balsamiq Mockups
Scrumy
JetBrains - ReSharper
Umbraco
NServiceBus
RavenDb
Web Sequence Diagrams
Ducksboard<-- NEW Friend!

 



Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers

 

Community Server (Commercial Edition)