How to link a TFS work item to another using the command line

How to link an existing TFS work item to another on the command line. Is there a command line option for this in TFS. I know that I can use tfpt.exe to create a work item or modify it, but I cannot find a way to link the work item to another.

+3


source to share


1 answer


Assuming you will be using the Linked link type, this should link your work items.



[string]$tfsURL="http://tfs:8080/tfs"
[psobject] $tfs=[Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer($tfsURL)
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.WorkItemTracking.Client")
$wit=$tfs.Getservice([Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore])

$item1=$tfs.WIT.GetWorkItem(1)
$item1.Open()
$item2=$tfs.WIT.GetWorkItem(3)
$linkType=$tfs.WIT.WorkItemLinkTypes.Item("System.LinkTypes.Related")
$witLink=New-Object Microsoft.TeamFoundation.WorkitemTracking.Client.WorkitemLink($linkType.ForwardEnd,$item2.Id)
$item1.WorkItemLinks.Add($witLink)
$item1.Validate()
$item1.Save()
$item1.Close()

      

+2


source







All Articles