Add Projects Extension - 188.8.131.52
The Add Projects extension for Visual Studio has been updated to version 184.108.40.206, adding a filter option to make it easier to find specific projects in a long list.
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.
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.
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.
To add a single project to the list, click the Add File button then select the project you want to include.
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.
You can remove projects from the list, just select them and press the Delete key or the Remove button.
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.
The settings for the extension are saved into an XML file located at
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
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.
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.
Like what you're reading? Perhaps you like to buy us a coffee?