Home > Visual Studio, Visual Studio Extensions > Friendly visual studio solution names for working with multiple branches

Friendly visual studio solution names for working with multiple branches

If you have the latest version of the Visual Studio 2010 extension VSCommands you can give your solutions friendly names that display in the window’s title bar.  This is nice when you are working in different branches, so that you can differentiate which solution you are actually looking at.  I wrote the following regex to put the Branch Name after the Solution name, so for example if you have the client solution open in both Dev and Release, one will be called “Client.sln – Dev” and the other “Client.sln – Release”.

To use this, in Visual Studio go to Tools -> Options -> VSCommands 2010-> IDE Enhancements and then paste in the following (without the quotes):

Friendly Name: “{solutionName} – {branchName}”

Friendly Name – Solution Path Regex: “.*\(?<branchName>.*)\(?<solutionName>.*(?:.sln))”

    WindowTitle1

WindowTitle2

Happy coding!

— Update —

Here is the new regex that I prefer to use instead now which shows the directories that the solution is sitting in:

Friendly Name: “{solutionName} – {dir1}{dir2}{dir3}”

Regex: “.*\(?<dir1>.*)\(?<dir2>.*)\(?<dir3>.*)\(?<solutionName>.*(.sln)Z)”

— Update 2 for VS 2012 —

These are the settings that I like to use for VS Commands 11 for VS 2012:

Branch Name Regex: “.*\(?<dir1>.*)\(?<dir2>.*)\(?<branchDirectoryName>.*)\(?<solutionFileName>.*(.sln)Z)”

Branch Name Pattern: “{branchDirectoryName} Branch”

Git Branch Name Pattern: “{git:head} Branch”

Main Window Title Pattern: “{solutionFileName} – {dir1}{dir2}{branchDirectoryName} ({sln:activeConfig}|{sln:activePlatform})”

Solution Explorer Window Title Pattern: “ – {solutionFileName} • {vsc:branchName}”

  1. Jon
    May 19th, 2013 at 14:52 | #1

    Great find, I didn’t know you could do that with an extension and at work we use code branches all the time. I can see how this will save me time!

  2. September 10th, 2013 at 11:41 | #2

    If you need a lightweight equivalent, you can try the following extension I have developed (“Rename Visual Studio Window Title”):
    http://visualstudiogallery.msdn.microsoft.com/f3f23845-5b1e-4811-882f-60b7181fa6d6

    I have not yet looked into the support of TFS/Git/Hg branch names (through the Visual Studio SDK API), but so far it works great for folder based branches (and many other scenarios).

  3. Josh
    January 27th, 2014 at 15:15 | #3

    I had to add an extra back slash for the reg-ex to work in VS 2010 Ultimate. Other than that worked great.

    .*\\(?.*)\\(?.*(?:.sln))

  4. Jay
    February 20th, 2015 at 05:38 | #4

    Hi My solution path is as below
    “D:\Dev\Release\v2013.1\CodeReview\AllProjects.sln”
    I need to use Branch Name as “2013.1”
    Can you tell me what should be the Branch Name Pattern

  5. Jay
    February 20th, 2015 at 06:54 | #5

    @Jay
    Found the solution
    .*\\(?.*).*\\(?.*)\\(?.*).sln

  6. Jay
    February 20th, 2015 at 06:55 | #6

    .*\\(?.*).*\\(?.*)\\(?.*).sln

  7. May 4th, 2018 at 00:56 | #7

    Hi, I think your site might be having browser compatibility issues.
    When I look at your blog in Safari, it looks fine but when opening in Internet Explorer, it has some overlapping.
    I just wanted to give you a quick heads up! Other
    then that, wonderful blog!

  1. No trackbacks yet.