如何使用 VS 包从源代码管理资源管理器获取当前分支路径 [英] How do i get current Branch path from Source control explorer using VS package
本文介绍了如何使用 VS 包从源代码管理资源管理器获取当前分支路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了 VS 扩展,通过右键单击它打开自定义表单,在源代码管理资源管理器上创建菜单命令,现在我想在该自定义表单中显示当前 TFS 路径(从用户右键单击的位置).与 TFS 相同分支和合并 => 分支"源路径.
I have created VS extension that creates a menu command on Source control explorer by right click on that it open custom form,Now i want to display current TFS path(from where user right click) in that custom form.Same as TFS "Branching and Merging => Branch" Source Path.
任何帮助表示赞赏.
推荐答案
您可以使用 VersionControlExplorerExt 对象及其属性 SelectedItems、CurrentFolderItem 等.从包中,它类似于:
You can use the VersionControlExplorerExt object with its properties SelectedItems, CurrentFolderItem, etc. From a package it would be something like:
private void MenuItemCallback(object sender, EventArgs e)
{
Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt versionControlExt;
Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExplorerExt versionControlExplorerExt;
EnvDTE.DTE dte;
try
{
dte = base.GetService(typeof(EnvDTE.DTE)) as EnvDTE.DTE;
versionControlExt = dte.GetObject("Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt")
as Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt;
versionControlExplorerExt = versionControlExt.Explorer;
MessageBox.Show(versionControlExplorerExt.CurrentFolderItem.LocalPath);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
这篇关于如何使用 VS 包从源代码管理资源管理器获取当前分支路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文