TFS doesn't provide that function out of the box, but you can use Powershell to combine existing TFS functions to get what you need.
My plan is to first use tf dir
get a list of files, then use tf view
to get files contents and finally feed the contents to Select-String
to find the string (or regex) we are looking for.
You can start with:
tf dir /recursive $/
but that list is probably going to be huge, so try to restrict your search to a small scope, like:
tf dir /recursive $/some/path/*.cs
Next step is to transform the results of the previous step into a format that we can then feed into tf view
. Here is a powershell script that does that:
(tf dir /recursive $/) -join "+" -replace ":", "" -replace "\+\+", "`n" -split "`n" | %{ $arr = $_ -split "\+"; $arr | select -Skip 1 | %{ $arr[0] + '/' + $_ } }
Now let's pipe the list into tf view
and then Select-String
:
... | %{ $file = $_ ; if (tf view "$file" /console | Select-String "some string") { Write-Host $file } }
Don't forget to change the part that says "some string"
.
Altogether, you get:
(tf dir /recursive $/) -join "+" -replace ":", "" -replace "\+\+", "`n" -split "`n" | %{ $arr = $_ -split "\+"; $arr | select -Skip 1 | %{ $arr[0] + '/' + $_ } } | %{ $file = $_ ; if (tf view "$file" /console | Select-String "some string") { Write-Host $file } }
Oh, and don't forget to replace the part that says "some string"
with your actual search query.