Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete dir with nAnt and exclude sub folder?

Tags:

nant

I'm looking for my build to delete the contents of a directory without touching a certain folder. Below is what I'm trying, and it even looks wrong to me...aside from the fact that it bombs when I run it. Do I need to be deleting the contents of the dir explicitly and at the same time exclude my Reports folder?

<delete includeemptydirs="true">
      <fileset dir="${PublishLocation}" >
        <exclude name="**Reports**"/>
      </fileset>
    </delete>

Cheers.

like image 648
bryan Avatar asked Dec 29 '22 02:12

bryan


1 Answers

It should be:

<delete>
  <fileset basedir="${PublishLocation}">
    <include name="**/*"/>
    <exclude name="**/Reports/**/*" />
  </fileset>
</delete>

Please notice the following:

  • includeemptydirs="true" is default
  • The attribute for fileset is basedir instead of dir
  • if you specify <exclude name="**/Reports/**" /> instead of <exclude name="**/Reports/**/*" /> all files named Reports are kept as well
like image 156
The Chairman Avatar answered Feb 12 '23 11:02

The Chairman