Delete dir with nAnt and exclude subfolder?

I am looking for my assembly to delete the contents of a directory without touching a specific folder. Below I try, and it even looks wrong to me ... except that it is bombing when I launch it. Should I explicitly delete the contents of the directory and at the same time exclude the My Reports folder?

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

Greetings.

+4
source share
1 answer

It should be:

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

Please note the following:

  • includeemptydirs="true" by 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 will be saved.
+10
source

Source: https://habr.com/ru/post/1301014/


All Articles