One more wrinkle to this problem that might be of interest.  In order for the 
<attrib> task to enable removal of a directory, it is necessary to append '/**' 
to any directory designation so as to include all the files in directory.  
Otherwise, the <delete> task will ignore the directory unless it's entire 
contents is also marked R/W.

This necessitates declaring directories to be removed in a <fileset> or 
<patternset> directive with a trailing '/**'.  Not necessary if the directory 
is ALREADY marked R/W - the delete command will work correctly.  BUT, if you 
must first invoke the <attrib>, then it is necessary to append '/**' to insure 
all enclosed files are also marked.

The resulting code is below:  First <patternset> entry delete a 'specified' 
directory.  Second <patternset> entry deletes all directories of a given name.  
Third <patternset> entry deletes all files matching a wild card specification 
anywhere in the directory tree.

Hope this is useful info.

Ken Parrish
Gomez, Inc.


        <patternset id="deploySiteCleanupSet" >
                <include name="Dashboard/**" />
                <include name="**/_vti_cnf/**" />
                <include name="**/XX*" />
                <include name="Dashboard2" />
        </patternset>

        <target name="PurgeDeployDirectory" >

            <echo message="PurgeDeployDirectory_dir = 
${PurgeDeployDirectory_dir}" />

                <attrib verbose="true" readonly="false" >
                        <fileset basedir="${PurgeDeployDirectory_dir}" 
defaultexcludes="false" >
                                <patternset refid="deploySiteCleanupSet" />
                        </fileset>
                </attrib>

                <delete verbose="true" includeemptydirs="true" >
                        <fileset basedir="${PurgeDeployDirectory_dir}" 
defaultexcludes="false" >
                                <patternset refid="deploySiteCleanupSet" />
                        </fileset>
                </delete>

        </target>




-----Original Message-----
From: Parrish, Ken [mailto:kparr...@gomez.com] 
Sent: Wednesday, April 22, 2009 3:45 PM
To: nant-users@lists.sourceforge.net
Subject: [NAnt-users] SOLVED: RE: Delete not removing directories ...

Scoured the documentation and discovered that <delete> will not act on ReadOnly 
files and directories.  Marked the entire directory tree as Read/Write.  Now 
everything is working as expected.

Next up, an investigation into the <attrib> task.

Ken



-----Original Message-----
From: Brass Tilde [mailto:brassti...@gmail.com] 
Sent: Wednesday, April 22, 2009 3:00 PM
To: nant-users@lists.sourceforge.net
Subject: Re: [NAnt-users] Delete not removing directories ...

>             <delete verbose="true" includeemptydirs="true" >
>                   <fileset basedir="${PurgeDeployDirectory_dir}" 
> defaultexcludes="false" >
>                         <include name="**/_vti_cnf" />
>                         <include name="**/XX*" />
>                         <include name="Dashboard" />
>                   </fileset>
>             </delete>
>
>       </target>

What happens if you use "**/_vti_cnf/" or "**/_vti_cnf/**" and
"Dashboard/" or "Dashboard/**" instead?

/bs
------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
NAnt-users mailing list
NAnt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users

------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
NAnt-users mailing list
NAnt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users

------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
NAnt-users mailing list
NAnt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to