I have a console application which creates a Work Item using TFS API. I want the application to start Visual Studio with the created work item open. I tried:
Process.Start("vstfs:///WorkItemTracking/WorkItem/123?url=http://mytfs:8080/tfs/mycollection")
This opens Visual Studio (I have 2013 update3), and opens a work item saying "opening work item 123...", but VS never actually finishes this open. If I close this window, I get an error The given key was not present in the dictionary
.
I tried from commandline/devenv, and both got me the same result:
C:\> start vstfs:///WorkItemTracking/WorkItem/123?url=http://mytfs:8080/tfs/mycollection
C:\> "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe" /Tfslink vstfs:///WorkItemTracking/WorkItem/123?url=http://mytfs:8080/tfs/mycollection
I tried opening another TFS item - a build - and that worked fine:
C:\> start vstfs:///Build/Build/111?url=http://mytfs:8080/tfs/mycollection
I could Open them in Web UI - but my users are more comfortable with Visual Studio.
So, How do I launch a work item in VS?
I found that I was able to use ShellExecute() to launch TFS with the desired work item loaded.
DECLARE INTEGER ShellExecute ;
IN SHELL32.dll ;
INTEGER nWinHandle,;
STRING cOperation,;
STRING cFileName,;
STRING cParameters,;
STRING cDirectory,;
INTEGER nShowWindow
ShellExecute(0, 'OPEN', "vstfs:///WorkItemTracking/WorkItem/999999?url=http://mytfsserver:8080/tfs/defaultcollection", '', '', 1)
This code sample is from VFP, but the premise should be the same everywhere.
Here is how to launch TFS with a workitem from the command window:
START vstfs:///WorkItemTracking/WorkItem/999999?url=http://mytfsserver:8080/tfs/defaultcollection
You can create a batch file and pass in the work item number to make it easier.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With