less than 1 minute read

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:

Friendly Name: {solutionName} - {branchName}

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

Window title 1

Window title 2

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}" (without the quotes)

Comments

Jon

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!

Erwin

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).

Josh

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

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

Jay

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

MS Diagnosis

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!

Leave a Comment

Your email address will not be published. Required fields are marked *

Loading...