我如何使用 VS 包从源代码管理资源管理器获取当前分支路径
How do i get current Branch path from Source control explorer using VS package
我创建了 VS 扩展,它通过右键单击打开自定义表单在源代码管理资源管理器上创建菜单命令,现在我想在该自定义中显示当前 TFS 路径(从用户右键单击的位置)form.Same 作为 TFS "Branching and Merging => Branch" 源路径。
感谢任何帮助。
应该通过 VersionControlExt.Explorer class. The VersionControlExt.Explorer.SelectedItems property should contain the server paths for the selected items. Here is an old blog post 公开源代码管理资源管理器的扩展性,它可能还包含一些对编写扩展有用的信息。
您可以使用 VersionControlExplorerExt 对象及其属性 SelectedItems、CurrentFolderItem 等。从一个包中,它类似于:
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 扩展,它通过右键单击打开自定义表单在源代码管理资源管理器上创建菜单命令,现在我想在该自定义中显示当前 TFS 路径(从用户右键单击的位置)form.Same 作为 TFS "Branching and Merging => Branch" 源路径。
感谢任何帮助。
应该通过 VersionControlExt.Explorer class. The VersionControlExt.Explorer.SelectedItems property should contain the server paths for the selected items. Here is an old blog post 公开源代码管理资源管理器的扩展性,它可能还包含一些对编写扩展有用的信息。
您可以使用 VersionControlExplorerExt 对象及其属性 SelectedItems、CurrentFolderItem 等。从一个包中,它类似于:
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());
}
}