Visual Studio 2008 Plug-in / Add-in development - Getting Started

andy picture andy · May 13, 2009 · Viewed 9.8k times · Source

In relation to this stackoverflow question, how would I go about creating my own Visual Studio 2008 plug-in?

I've checked the Visual Studio Developer Centre on MSDN, but the amount of info is overwhelming. There are loads of project types, and I don't even know where to start.

Where should I start looking if I want to write something which meets the following requirements:

  1. A plug-in that runs like a "service" in Visual Studio, and is able to poll Visual Studio for information, and handle Visual Studio events.
  2. The info I'd like to access from VS are things like, what projects are currently open, who has them open, and other solution/project file based info.
  3. The events I'd like to be able to handle are things like, the opening/closing/editing/creating/deleting of Solutions / Projects / individual files.
  4. I'd also like to be able to handle any interaction with VS on a per solution basis. So, I'd like to handle any interaction with files, even code editing, but also, just other interaction, like with the menus, or just the IDE itself.

As well as these, I'd also like to be able to store data somewhere. Where is this usually done? Can I add Metadata to the Solution file? Or, does it make sense to save this info to a small local instance of a database, that is somehow attached to the solution..?

I just need a push in the right direction, is any of this possible? What part of the Visual Studio Developer Centre should I focus on? What APIs should I check out?

cheers!

Answer

KristoferA picture KristoferA · May 13, 2009

An add-in can do most of that. There's a template in VS2008 for creating a base add-in.

I have an add-in that you can download that hooks into the solution/project load events etc - it is free and comes with source code ( http://www.huagati.com/projectloader/download/huagatiprojectloader.zip ). This particular add-in detects when projects/solutions are loaded and pre-loads referenced assemblies to work around a CLR bug that can cause VS2008 to crash. Anyway, the source code for it shows how to detect some of the events you're looking for.

Other than that, the definitive resource on add-in development and all the little quirks and tricks involved is Carlos Quintero's blog ( http://msmvps.com/blogs/carlosq/ ) and the "howto" article series on his website ( http://www.mztools.com/resources_vsnet_addins.aspx ).

Craig Skibo's blog ( http://blogs.msdn.com/craigskibo/ ) also has some useful tips.