Web developer from Sydney Australia. Currently using asp.net, mvc where possible.

Sunday, September 25, 2011

Project to File Reference Switcher for Visual Studio

Switching from project to file references in visual studio has always been a pain. Once you add a project to the solution you have to go find all the locations the assembly is referenced by file path and remove and update to a project reference.

On top of playing hide and seek with references, the actual act of changing references is a slow and painful experience.

So I decided to experiment and write my first visual studio extension, "Reference Switcher"

Once installed it will sit patiently in the background and only activate when you add or remove a project from the solution.

When you add a project, it gets the assembly name defined by the project and then checks to see if other projects in the solution are referencing that assembly name. If they do, it will open a alert box (sorry, send a push request) and ask if you would like to switch the file reference to a project reference. Just hit OK and it will go ahead and switch all the references for you.

When you remove a project, it all happens in reverse. So any project references that it changed are restored back to the original file based reference.

Here are some screen shots of the extension in action:

1) Adding a existing project (existing projects have a file references to this one)


2) Shows projects that can be updated to use a project reference


3) Now the references have changed to Project References



4) When the project is removed, Reference Switcher confirms before changing the references back to there original location


5)Now the reference has changed back to a file reference


That's all there is to it. Small & simply but very handy.

The extension source can be found on git hub here:
Extension can be found in the gallery here:

Shout it

kick it on DotNetKicks.com