Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TFS Find matching Files with OR

Tags:

build

tfs

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.

like image 414
joe Avatar asked Feb 15 '12 19:02

joe


People also ask

How do I search for a file in TFS?

Right-Click In the File List, right-click the file you want to check in and select Source Control > Check In (for selected files) or Source Control > Project > Check In All (for all files in the project). Local Toolbar In the File List, select the file(s) you want to check in.

How connect VS 2019 to TFS?

From the Visual Studio Tools menu, select Options, then select Source Control > Plug-in Selection. Select Visual Studio Team Foundation Server. For Visual Studio Team Foundation Server, enter the name and port number for the Azure DevOps Proxy Server. Select Use SSL encryption (https) to connect.


1 Answers

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"
like image 51
DaveShaw Avatar answered Oct 05 '22 01:10

DaveShaw