If you work hard with branches, one of the most annoying mistakes you can make is to change the wrong branch. I have a project consisting of several solutions, each of which contains various user interface projects, each of which uses WCF as its back end, but is released as separate software. Whenever we release a new version of one of the user interfaces, we create a branch, so we can support patch, SP, etc.
A simple solution is to create a Visual Studio macro ( http://www.helixoft.com/blog/archives/32 ) that uses a regular expression to parse the full path of the solution file, search for a specific folder structure that identifies the branch. Here is the complete code:
Declare Auto Function SetWindowText Lib "user32" (ByVal hWnd As System.IntPtr, _ ByVal lpstring As String) As Boolean Private Sub showTitle(ByVal title As String) SetWindowText(New System.IntPtr(DTE.MainWindow.HWnd), title & " - " & DTE.Name) End Sub Private Sub SolutionEvents_Opened() Handles SolutionEvents.Opened Dim m As Match = Regex.Match( _ DTE.Solution.FullName, _ "Branch.*\\(?<project>.*)\\(?<branch>.*)\\(?<sln>.*)\.sln", _ RegexOptions.IgnoreCase) If (m.Success) Then Dim project As String = m.Groups("project").Value Dim version As String = m.Groups("branch").Value Dim sln As String = m.Groups("sln").Value showTitle(String.Format("BRANCH [{0}] - Project {1} - {2}", _ version, project, sln)) End If End Sub
You need to paste this code into the macro editor, which opens from the menu "Tools" β "Macros" β "Macros" IDE
From an open editor, you simply double-click on MyMacros, expand EnvironmentEvents, and you can add your own code for each handler supported by Visual Studio.
If you look at the code, I will just put in a regular expression that allows me to parse the typical branch path structure that I have in my projects, where I have Branch \ someothertext \ nameoftheproject \ branchnumber \ solutionfile.sln.
NTN Greetings, Tarun
source share