12 Oct 2013

Visual Studio Extension for adding multiple projects to a solution


My solutions have lots of references to other projects, either common libraries or unit testing libraries. Neither of these scenarios lend well to manual binary references or NuGet packages, so I have lots of source code projects loaded for each solution.

When creating a new solution (or retro fitting an existing solution to use new libraries), I end up using File | Add | Existing project a lot. As I was curious about how extensions in Visual Studio worked, I decided to write a very simple one to ease the grunt work of adding multiple common projects.

The last time I wrote an extension (or addin as they were called back then :)) for an IDE was vbCodeShield for Visual Basic 6 and that was years ago. I was incredibly surprised to find that writing an extension for Visual Studio is pretty much the same as it was (if not worse) - a horrible mass of unintuitive COM interfaces and clunky code. Whatever happened to the managed dream?

On the plus side, they are much easier to debug than I remember VB6 addins being. Or at least, they would be if Resharper didn't raise continuous exceptions while running in Visual Studio's Experimental Instance.

Almost Ranting

Still, I created the extension without too much pain, although I have to say it's some of the code I'm least proud of, and I'm certainly not going to walk through the code on this blog.

I gather you're supposed to use WPF to write extensions, but well... I wasn't going to learn WPF and the DTE at the same time. I actually tried (the aborted attempt is still in the source tree) to use a WPF dialog as recommended by the MSDN docs, but after finding simple things like checked list boxes (or even just list views with checkboxes) seemed to have a learning curve equal to the Moon landing, I went back to Windows Forms and had it knocked up in no time.

The code is messy, isn't using WPF, doesn't have a great deal of exception handling, and is full of artefacts from the wizard generation. But, it does seem to work.

Using the extension

To use the extension, open the Tools menu and choose Add Projects. This will open a lovely unthemed Windows Forms dialog containing an empty list of projects.

Adding a single project to the MRU

To add a single project to the list, click the Add File button then select the project you want to include.

Adding multiple projects to the MRU

To add multiple projects to the list, click the Add Folder button, then select a folder. After you've selected a folder, all projects in this folder and its subfolders will be added to the list.

Removing projects from the MRU

You can remove projects from the list, just select them and press the Delete key or the Remove button.

Adding projects to your solution

Just place tick each project you want to add to your solution, then click the OK button. It will then try and add each selected project to your solution, skipping any that are already present.

Configuration Settings

The settings for the extension are saved into an XML file located at %AppData%\Cyotek\VisualStudioExtensions\AddProjects\config.xml.

<?xml version="1.0"?>
<ExtensionSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Filter>C# Projects (*.csproj)|*.csproj|All Files (*.*)|*.*</Filter>
    <!-- SNIP -->

The Filter element lets you specify the filter for the Add File dialog, and is also used by Add Folder to search for appropriate files - if you write in Visual Basic rather than C# you'll probably want to change the filter to be vbproj rather than csproj!

The Projects element stores the MRU list of projects.


That's pretty much it - it's a very simple extension, but potentially a starting point for something more interesting.

You can download the code or the compiled VSIX installer from the links below.

Related articles you may be interested in:



Signed Visual Studio extension installer for the Visual Studio Extension for adding multiple projects to a solution blog post.

18 April 2014 87.64 KB

Source code for the Visual Studio Extension for adding multiple projects to a solution blog post.

12 October 2013 41.65 KB


  • Gravatar
    # Param
    28/01/2014 11:19

    Good and usefull ... thanks

  • Gravatar
    # Param
    28/01/2014 12:26

    Its really awesome tool. I tried many other urls, but i could not get the proper solution. Finally i found it here.. thanks Richard.

  • Gravatar
    # your name
    11/02/2014 21:55

    Thanks for this

  • Gravatar
    # Nix
    18/03/2014 14:57

    Very useful tool, thanks for sharing it :)

  • Gravatar
    # Dwain Browne
    03/05/2014 18:59

    You are a life saver!! I was seriously beginning to question if my job was to code or add references to projects. Thanks a mill.

  • Gravatar
    # m.qayyum
    13/05/2014 13:03

    helped alot, thanks

  • Gravatar
    # Victor
    17/07/2014 20:12

    Thanks a lot. This saved me a lot of time - I wish I'd discovered it earlier!

Leave a Comment

While we appretiate comments from our users, please follow our posting guidelines. Have you tried the Cyotek Forums for support from Cyotek and the community?