joe
joe

Reputation: 787

TFS Find matching Files with OR

So I want to find all the .xml and .pdb files and delete them from a build output folder. I can do this one at a time, but can I do this as one find matching files.

Upvotes: 5

Views: 4025

Answers (1)

DaveShaw
DaveShaw

Reputation: 52798

If you are doing this as part of the TFS build process template then you need a few activities and a variable. I'll do my best to talk you through it.

  1. Create a Sequence somewhere after the build has completed - I put mine just after where the files were copied to the Drop Location.
  2. Create a variable scoped to the Sequence called matchedFiles of type IEnumerable<String>
  3. Add a FindMatchingFiles Activity to the Sequence and set the properties as follows
    • MatchPattern: String.Format("{0}\**\*.xml;{0}\**\*.pdb", BuildDetail.DropLocation) . You can change it to use BinariesDirectory if you are not cleaning the Drop Folder.
    • Result: matchedFiles
  4. Add a ForEach Activity to the sequence and set the properties as follows:
    • Type: String.
    • Foreach file in matchedFiles
    • In the Body add a new InvokeMethod activity and set the properties as follows:
      • TargetType: System.IO.File
      • MethodName: Delete
      • Parameter: Direction: In Type: String Value: file

Now to avoid having a every File Delete in your build log, open the Process Template XAML with Visual Studio, find the InvokeMethod step, and add the following Attribute to the XAML:

mtbwt:BuildTrackingParticipant.Importance="None"

Upvotes: 19

Related Questions