Create a particular type of link between two WorkItem's in TFS using PowerShell

StackOverflow https://stackoverflow.com/questions/23614464

  •  20-07-2023
  •  | 
  •  

Question

I am creating test cases (Test Case type of task) in PowerShell and I am trying to link them to a story (Product Backlog Item) as "Test Cases" and not as ordinary links.

Suppose $WIT is the WorkItemStore and $testcaseId and $storyId are valid IDs. If I do:

$testCase = $WIT.GetWorkItem($testcaseId)
$workitem.Links.Add($storyId)
$workitem.Save()

I will have a bunch of "normal" links from the test case to the story, which is not what I want.

In C#, this seems to be achievable by creating a new RelatedLink and specifying the type of the link. Here's a snippet (more info here)

source.Links.Add(new RelatedLink(linkTypeEnd, approval.Id));

Is there any way to do the same in PowerShell?

Était-ce utile?

La solution

You can do it in Powershell the same way that you do it in C#... that's the awesome power of PowerShell :)

[Microsoft.TeamFoundation.WorkItemTracking.Client.Hyperlink]$NewLink = New-Object -TypeName Microsoft.TeamFoundation.WorkItemTracking.Client.Hyperlink -ArgumentList $newlocation
$wit.Links.Add($NewLink)

I first use the PowerShell function above to pull in the relevant DLL's then I have access to the Above is the code to create and add a new Hyperlink. From this you should be able to easily create other types of links.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top