tags:

views:

453

answers:

2

I am attempting to delete a folder that is a svn checkout of my project so that I can do a fresh checkout. The problem is whenever I try to delete this folder using a nant delete task I keep getting the following error:

[delete] Deleting directory 'C:\projects\my_project\Trunk'.

BUILD FAILED

c:\Projects\my_project\default.build(63,4):
Cannot delete directory 'C:\projects\my_project\Trunk\SomeFolder\AnotherFolder'.
    The directory is not empty.

Is there a trick to delete a working copy with nant here? I tried doing a delete targeting only the .svn directories, but nant wouldn't delete all of them for some reason. Here is the task I was using for that, but it didn't work:

 <delete>
  <fileset basedir="myproject\trunk">
   <include name="\**\.svn" />
  </fileset>
 </delete>

Any ideas would be greatly appreciated!

+1  A: 

If you want to delete the whole trunk directory

<delete dir="myproject/trunk" />

I can't verify right now if <include ... /> is even able to select directories not files.

Else if you just want to delete the .svn directories

<delete>
    <dirset basedir="myproject\trunk" defaultexcludes="false">
        <include name="**/.svn" />
    </dirset>
</delete>

I used dirset as I'm not sure if fileset even selects directories. Maybe it gets interpreted as "give me all files which are named .svn" Notice the use of defaultexcludes="false" and check here <fileset documentation> what the defaultexcludes are (e.g. **/.svn exactly what you tried to include)

jitter
see my response below. close
Sean Chambers
+1  A: 

@jitter, you were very close

first there is no dirset, I got an error when attempting to use this. here is what actually worked

<delete>
  <fileset basedir="myproject\trunk" defaultexcludes="false">
    <include name="**/.svn" />
    <include name="**/.svn/**/*" />
  </fileset>
</delete>

fileset will include directories if you have the correct selections. I think the key was using defaultexcludes="false" and using

**/.svn/**/*

which properly selects subfolder of the .svn folders.

Thanks!

Sean Chambers
jitter