问题
I am developing a Visual Studio extension (VS Package).
I am trying to get the Source Control branch name for a project/solution.
The only source control service available in the VS SDK is SVsSccManager but that doesn't provide any means of retrieving the source control branch name.
Also looked at DTE.SourceControl but alas, it doesn't give branch info.
I really don't want to develop my own Source Control plug-in to simply retrieve the branch name (this feels like total overkill).
Is there any way of retrieving the current branch name in source control for a solution/project?
Thanx in advance.
回答1:
Visual Studio Extensibility (VSX) - Get the current branch name
If you are use git, there is already Visual Studio extension that displays your current Git branch on the title bar: ShowMyGitBranch.
You can check the source code about this extension for more details:
https://github.com/thiagotts/show-my-git-branch
If you are use TFS, you can use API get branch for a project:
https://social.msdn.microsoft.com/Forums/en-US/89802f2e-f410-4a3a-a9c1-f776a3dd884e/api-get-branch-for-a-project?forum=tfsversioncontrol
Hope this helps.
来源:https://stackoverflow.com/questions/52087358/visual-studio-extensibility-vsx-get-the-current-branch-name