Skip to content

Instantly share code, notes, and snippets.

@adamdriscoll
Created June 10, 2016 15:00
Show Gist options
  • Save adamdriscoll/712d130833256190e120b9e8882914ee to your computer and use it in GitHub Desktop.
Save adamdriscoll/712d130833256190e120b9e8882914ee to your computer and use it in GitHub Desktop.
TFS BranchObject from XML
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><QueryBranchObjectsResponse xmlns="http://schemas.microsoft.com/TeamFoundation/2005/06/VersionControl/ClientServices/03"><QueryBranchObjectsResult><BranchObject><Properties><RootItem it="$/SystemCenter/Main" ctype="8"><Version xsi:type="ChangesetVersionSpec" cs="7861" /></RootItem><Description>Converted to Branch after Code given by Adam</Description><Owner>adam@driscoll.com</Owner><OwnerDisplayName>Adam Driscoll</OwnerDisplayName><OwnerUniqueName>adam@driscoll.com</OwnerUniqueName><BranchMappings /></Properties><DateCreated>2014-12-17T15:48:34.037Z</DateCreated><ChildBranches /><RelatedBranches /></BranchObject></QueryBranchObjectsResult></QueryBranchObjectsResponse></soap:Body></soap:Envelope>
[Reflection.Assembly]::LoadFrom("C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\wgyzjlaf.ik1\Microsoft.TeamFoundation.VersionControl.Client.dll") | Out-Null
$Reader = [Xml.XmlReader]::Create("$PSScriptRoot\Branch.xml")
while($reader.LocalName -ne "BranchObject" -and $reader.Read())
{
Write-Verbose "Skipping soap envelope"
}
while ($reader.NodeType -eq [System.Xml.XmlNodeType]::Element -and $reader.Name -eq "BranchObject")
{
[Microsoft.TeamFoundation.VersionControl.Client.BranchObject]::FromXml($null, $reader)
}
$reader.ReadEndElement()
$reader.Dispose()
@adamdriscoll
Copy link
Author

To collect the XML for a branch operation:

  1. Open Fiddler and target the DenEnv.exe process
  2. In Visual Studio open Source Control Explorer, right click on a branch and click Branches and Merging -> View Branch Heirarchy
  3. In Fiddler find the soap message and click decode.
  4. Open the Raw view of the soap envelope and copy that into your test file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment