开发者

Nant foreach include exclude filter not working as expected

I wish to exclude particular files from a nant (0.91) target and process the remainder.

Here's the code snippet, which shows I want to include all .js files but exclude foo. foo is not being excluded. I've tried putting the exclude before the include but same result.

<foreach item="File" in="${built.web.directory}\Content\js" property="filename">
    <in>
        <items basedir="${built.web.directory}\Content\js">
            <include name="/**/*.js" />
            <exclude name="**/foo.1.2.js" />
            <exclude name="foo.1.2.js" />
        </items>
    </in>
    <do>
        <echo message="Compressing ${filename}" />
        <exec program="${packer.exe}" commandline="-o ${built.web.directory}\Content\js\${path::get开发者_开发技巧-file-name(filename)} -m jsmin ${filename}" />
    </do>
</foreach>


You have specified the in attribute on foreach which is overriding the items element. Try changing:

<foreach item="File" in="${built.web.directory}\Content\js" property="filename">

to:

<foreach item="File" property="filename">


This seems to work

<fileset id="javascript.files" basedir="${built.web.directory}\Content\js">
    <include name="/**/*.js" />
    <exclude name="**/foo.1.2.js" />
    <exclude name="**/*.min.js" />
</fileset>


<foreach item="File" property="filename">
    <in>
       <items refid="javascript.files" />
    </in>
    <do>
        <echo message="Compressing ${filename}" />
        <exec program="${packer.exe}" commandline="-o ${built.web.directory}\Content\js\${path::get-file-name(filename)} -m jsmin ${filename}" />
    </do>
</foreach>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜