如何在Visual Studio扩展中选取所选源文件?

问题描述:

我正在写视觉工作室扩展。如何在Visual Studio扩展中选取所选源文件?

我想要做的是运行一个菜单选项(确定完成这个),它选取使用源代码管理器选择的文件并使用它。

任何想法如何我可以得到这个文件? 我真的需要文件本身和TFS路径$/....

这不是“解决方案资源管理器”中选定的文件。

感谢您的期待。

您可以使用这样的代码:

Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt versionControl = 
       DTE.GetObject("Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt") 
      as Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt; 
string file = versionControl.Explorer.CurrentFolderItem.SourceServerPath; 

一个完整的样本见Browse one folder up in Sorce Control Explorer

+0

这看起来是正确的,但我没有得到一个参考TeamFoundation 我正在使用Visual Studio社区2015. 我需要什么来安装,否则为了得到它? –

+0

@KevinBadger请参阅http://stackoverflow.com/questions/32438852/where-is-microsoft-visualstudio-teamfoundation-versioncontrol-dll-in-visual-stud –