Background

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

Accessing the extension
Accessing 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

Using the extension
Using the extension

Just 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
<?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>
  <Projects>
    <string>C:\Checkout\cyotek\source\Libraries\Cyotek.ApplicationServices\Cyotek.ApplicationServices.csproj</string>
    <string>C:\Checkout\cyotek\source\Libraries\Cyotek.ApplicationServices.Commands\Cyotek.ApplicationServices.Commands.csproj</string>

    <!-- SNIP -->

    <string>C:\Checkout\cyotek\source\Libraries\Cyotek.Windows.Runtime.Support\Cyotek.Windows.Runtime.Support.csproj</string>
    <string>C:\Checkout\cyotek\source\Libraries\Cyotek.Windows.Runtime.Testing\Cyotek.Windows.Runtime.Testing.csproj</string>
  </Projects>
</ExtensionSettings>

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.

Closing

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

Downloading

The best place to get the extension is from the extension page on the Microsoft Visual Studio Gallery. This also ensures you get notifications when the extension is updated. (Don't forget to post a review!)

You can also grab the source directly from our GitHub page.

Legacy links available below are no longer maintained.

Update History

  • 2013-10-12 - First published
  • 2024-10-14 - Updated to include Visual Studio Gallery and
  • 2020-11-21 - Updated formatting

Like what you're reading? Perhaps you like to buy us a coffee?

Donate via Buy Me a Coffee

Donate via PayPal


Files


Comments

# Param

Good and usefull ... thanks

Reply

# Param

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

Reply

# your name

Thanks for this

Reply

# Nix

Very useful tool, thanks for sharing it :)

Reply

# Dwain Browne

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.

Reply

# m.qayyum

helped alot, thanks

Reply

# Victor

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

Reply

# Zoltán Lehóczky

Would you add this to the VS Gallery please? Would also gain some visibility.

Reply

# Richard Moss

I've been meaning to do this for ages. Of course, I've been meaning to update it to use WPF and a bunch of other stuff for ages too and still haven't. But I've now uploaded it to the gallery - http://visualstudiogallery.msdn.microsoft.com/dc3adb4b-3b94-4ca0-97fd-3c817bd14a77. And who knows, maybe I'll find some time to update it further in future.

Regards; Richard Moss

Reply

# Michael Clark

Thanks for this. It has saved me from doing this manually for over 100 projects. Could you allow ordering the results by path to allow us to exclude particular areas of the codebase?

Reply

# Richard Moss

Thanks for the comment, glad you found it useful. And your suggestion is definitely reasonable, I'll be sure to add that to the next update!

Regards; Richard Moss

Reply

# Richard Moss

The latest version (1.0.2.0) now adds the ability to sort the listview on any column. If you grabbed the from the Microsoft Gallery (https://visualstudiogallery.msdn.microsoft.com/dc3adb4b-3b94-4ca0-97fd-3c817bd14a77) then you ought to get an update notification. If you didn't, go get it now!

Regards; Richard Moss

Reply

# Vicky

Great tool, thanks, saved me loads of time!! One possible improvement. When you add projects by folder, could you get it to automatically uncheck those that are already in a solution?

Reply

# Richard Moss

Glad you like it! Thanks for the suggestion, I'll look at that when I next update the extension.

Regards; Richard Moss

Reply

# Dan

Awesome - thank you :)

Reply

# pedro

hi! is any chance of this working at vs2008?

Reply

# Richard Moss

Hello,

In theory yes, but the current code is an extension, and I think it was VS2010 that introduced extensions. VS2008 and below uses an older model called an add-in - the code would need to be converted to be an addin rather than an extension. This isn't something I'm going to do as VS2008 is several iterations obsolete, and with the free Community Edition of VS2013 supporting extensions (unlike older Express editions) there probably isn't even a need.

Regards;
Richard Moss

Reply

# Chris

Thanks!

Reply

# Jose

Holy cow! Thanks for this! This has just saved me around 30 mins of painful and worthless adding!!!

Reply

# John M. Długosz

Just what I'm looking for — except that it is not available for VS2017. Any plans on updating it? Any additional rant on making extensions incompatible across versions?

Reply

# Richard Moss

John,

Thanks for the comment. The extension should work in VS2017 - I believe it gives a warning saying that it may not be fully compatible, but I have heard from users that it works fine. With that said, I haven't installed any extensions into my own VS2017 instance yet (I'm too busy marvelling how fast things work when Resharper isn't installed ;)) so I haven't personally tested it.

A PR has been submitted by another user for adding proper VS2017 support - I haven't evaluated it yet; it's on the list of things to do Soon(tm).

I don't have a new rant at present, although I suspect that is coming when I discovered I have to have multiple VS versions installed to test this properly if I want to avoid breaking support for older VS versions as happened when it was upgraded for VS2015.

Regards;
Richard Moss

Reply

# Richard Moss

Although, I am not-so-silently ranting now as that last paragraph needs reworking and I've just discovered that a recent change to the site to pre-process markdown formatting in comment content has inadvertently broken the editing of comments. Oh well.

Reply

# Joseph

Just a note: I was struggling with attempting to recompile the source for more control over the filters, but found the easiest way to import projects that are not .csproj using your extension is to just click Add File... open the default filter in the bottom right, then search in a directory for the extension like *.rptproj then select all-> okay and press enter to upgrade each. This allowed me to add 500 projects in a matter of a few minutes. Thanks a ton, Richard!

Reply

# Richard Moss

Thanks for the comment; I'm glad you found it useful!

Reply