开发者

How to Recursively Delete wildcard files in TFS Build?

开发者 https://www.devze.com 2022-12-17 14:40 出处:网络
I want to recursively delete files that match a certain pattern as part of my post-build cleanup routines in TFS Build. I\'ve tried this...

I want to recursively delete files that match a certain pattern as part of my post-build cleanup routines in TFS Build. I've tried this...

<Delete Files="T:\DeploymentDir\**\A*" />

No errors in th开发者_Python百科e build, but it doesn't work.


Modify your TFSBuild.proj file and add the following lines at the very end (just before closing ):

<Target Name="AfterDropBuild">
<ItemGroup>
   <FilesToDelete Include="$(DropLocation)\$(BuildNumber)\**\temp*.*" />
</ItemGroup> 

<Delete Files="@(FilesToDelete)" TreatErrorsAsWarnings="true"/>
</Target>


I don't think the Delete task will automatically expand the wildcard. You'll need to specify an itemgroup first, then pass that into the Delete task:

<ItemGroup>
  <FilesToDelete Include="T:\DeploymentDir\**\A*"/>
</ItemGroup>

<Delete Files="@(FilesToDelete)"/>

With MSBuild 3.5 onwards you can include the ItemGroup in the same target as the Delete task.

0

精彩评论

暂无评论...
验证码 换一张
取 消