如何从外部过程中打开Visual Studio中的现有工作项? [英] How do open an existing work item in Visual Studio from an outside process?

查看:119
本文介绍了如何从外部过程中打开Visual Studio中的现有工作项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个控制台应用程序,该应用程序使用TFS API创建工作项.我希望应用程序在打开创建的工作项的情况下启动Visual Studio.我试过了:

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")

这将打开Visual Studio(我有2013 update3),并打开一个工作项,显示正在打开工作项123 ...",但是VS从未真正完成此打开.如果关闭此窗口,则会显示错误The given key was not present in the dictionary.

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.

我从命令行/devenv尝试过,都得到了相同的结果:

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

我尝试打开另一个TFS项目-构建-效果很好:

I tried opening another TFS item - a build - and that worked fine:

C:\> start vstfs:///Build/Build/111?url=http://mytfs:8080/tfs/mycollection

我可以在Web UI中打开它们-但我的用户对Visual Studio感到更满意

I could Open them in Web UI - but my users are more comfortable with Visual Studio.

那么,如何在VS中启动工作项?

So, How do I launch a work item in VS?

推荐答案

我发现我能够使用ShellExecute()启动TFS并加载所需的工作项.

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)

此代码示例来自VFP,但前提在所有地方都应相同.

This code sample is from VFP, but the premise should be the same everywhere.

  • 在Shell32.dll中声明功能
  • 使用适当的参数调用函数

以下是在命令窗口中使用工作项启动TFS的方法:

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.

这篇关于如何从外部过程中打开Visual Studio中的现有工作项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆