title: How to delete all file and folders with msbuild
body: <p>How can I delete all files and folders from a given path?</p>
  
  <p>I tried this, but I'm unable to select the directories.</p>
  
  <pre><code>&lt;Target Name="CleanSource" Condition="$(path)!=''"&gt;
  
      &lt;Message Text="path=$(path)"/&gt;
  
      &lt;ItemGroup&gt;
        &lt;fileToDelete Include="$(path)\**\*.*" /&gt;
        &lt;directoryToDelete Include="$(path)\**\" /&gt;&lt;!these doest not select any directory at all--&gt;     
      &lt;/ItemGroup&gt;
  
      &lt;Message Text="file to delete:@(fileToDelete)"/&gt;
      &lt;Message Text="directory to delete:@(directoryToDelete)"/&gt;
  
      &lt;Delete Files="@(fileToDelete)" /&gt;
      &lt;Message Text="file effectively deleted:@(DeletedFiles)"/&gt;
      &lt;RemoveDir Directories="@(directoryToDelete)" /&gt;
      &lt;Message Text="Directory effectively deleted:@(RemovedDirectories)"/&gt;
  
  &lt;/Target&gt;
  </code></pre>