How can I craft up a NAnt include/exclude pattern to include the root /bin directory and its files, but exclude bin directories that are children of other directories?
<target name="createArtifacts">
<copy todir="${destdir}" includeemptydirs="false">
<fileset basedir="${sourcedir}">
<include name="**" /> <!-- this will get the root \bin folder -->
<exclude name="**\bin\*.pdb" />
<exclude name="**\bin\*.xml" />
...
</fileset>
</copy>
</target>
I want this to exclude any bin folder that is not the root bind folder:
<exclude name="\**\bin\" />
But it ends up removing the root bin as well.
You have been very close to the answer. You should just add an asterisk as a very first character in the exclude
pattern. Taking your sample, this will loot like this:
<target name="createArtifacts">
<copy todir="${destdir}" includeemptydirs="false">
<fileset basedir="${sourcedir}">
<include name="**" />
<exclude name="*\**\bin\*.pdb" />
<exclude name="*\**\bin\*.xml" />
...
</fileset>
</copy>
</target>
That first asterisk basically means "we don't want to take first-level folder into consideration".