locked
TFS REST API RRS feed

Answers

  • Hi Champs,

    You could try to use Powershell with C# to get branches in a team project:

    $TfsUrl='http://{servername}:8080/tfs/DefaultCollection'
    $project='$/{projectname}'
    
    
    add-type -Path 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Microsoft.TeamFoundation.VersionControl.Client.dll'
    add-type -Path 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Microsoft.TeamFoundation.Client.dll'
    
    $tfs = new-object Microsoft.TeamFoundation.Client.TfsTeamProjectCollection(New-Object Uri($TfsUrl))
    
    $tfsVersionControl = $tfs.GetService([Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer])
    
    $objallbranch = $tfsVersionControl.QueryRootBranchObjects("full")
    
    
      Write-Host branches in $project
       foreach ($branchObject in $objallbranch)
       {
                       if ($branchObject.Properties.RootItem.Item.Contains($project))
                       {
                           write-host $branchObject.Properties.RootItem.Item
                       }
       }
    
    

    Best Regards


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Saturday, September 16, 2017 8:59 AM