Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSBuild Task syntax for deleting files

I'm trying to write a MSBuild Task that deletes the Obj directory and PDBs from my bin folder on my production build scripts and can't seem to get it to work right.

Does anyone have an example where they do this or similar, or a link to a simple example of removing files and a directory with MSBuild?

like image 815
Chris Marisic Avatar asked Sep 25 '09 17:09

Chris Marisic


People also ask

How do you automate delete files?

Setting a folder to auto-deletebutton for the folder and select Settings. From the Folder Settings screen scroll down to Automated Actions>Delete or Unshare. Check the Auto-delete this folder on a selected date checkbox and choose a date you want the folder to be deleted.

What does MSBuild clean do?

When you clean a build, all intermediate and output files are deleted, leaving only the project and component files. From the project and component files, new instances of the intermediate and output files can then be built.


1 Answers

You can delete the files in those directories first and then the dir itself with

<Target Name="SomeTarget">     <ItemGroup>         <FilesToDelete Include="Path\To\Obj\**\*"/>     </ItemGroup>        <Delete Files="@(FilesToDelete)" />        <RemoveDir Directories="Path\To\Obj\" /> </Target> 
like image 198
Sayed Ibrahim Hashimi Avatar answered Oct 06 '22 12:10

Sayed Ibrahim Hashimi