NAnt include/exclude pattern to include root bin folder but not child bin folders

StackOverflow https://stackoverflow.com/questions/16676276

  •  30-05-2022
  •  | 
  •  

문제

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".

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top