开发者

Nant foreach include exclude filter not working as expected

开发者 https://www.devze.com 2023-02-10 12:54 出处:网络
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.

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

精彩评论

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

关注公众号