0

I have a TFS MSBuild project from there I am trying to delete directories whose names I would not want to explicitly specify from MSBuild [Since they are many and may change in the future] but want to retain one directory.

In the below example I want to delete all folder under "Web" but want to retain "bin" directory.

-Web
    --bin
    --folder 1
    --folder 2
    --folder 3
    ...
    ...

    <ItemGroup>
  <OutputDirs Include="$(DropLocation)\$(BuildNumber)\Web\**\*.*" Exclude="$(DropLocation)\$(BuildNumber)\Web\bin" />
</ItemGroup> <RemoveDir Directories="@(OutputDirs)" />

The above example works for files but not Directories, is there a exclude option I can use without specifying directories that I want to include.

thanks in advance.

user973374
  • 31
  • 3
  • Doesnt seem to be any support in inbuilt task. You should backup the directory delete all and then restore it. – allen Feb 03 '13 at 18:18
  • Try to change `Include="$(DropLocation)\$(BuildNumber)\Web\**\*.*"` to `Include="$(DropLocation)\$(BuildNumber)\Web\**\*"`, because the `*.*` will commonly not find directories, because they usually don't have a dot in their name. – MikeR Feb 04 '13 at 08:15
  • @Mike, I tried your suggestion, this still deletes all files under the folders but keeps the empty folders. I guess the only way to put some logic here is to invoke dos command line from within MSBuild. Any other suggestions appreciated. – user973374 Feb 13 '13 at 15:23
  • @allen, this adds so much extra time to the build that it is not worth the effort. – user973374 Feb 13 '13 at 15:28
  • If you can use a `Contains`, than you could iterate over OutputDirs and have a condition that it not includes `web\bin\ ` . Here is discussed about the `Contains` http://stackoverflow.com/questions/3289538/is-there-any-msbuild-task-to-check-if-a-string-contains-another-string-similar – MikeR Feb 13 '13 at 16:38

0 Answers0