The Spectrum of Visual Studio .NET Automation
Visual Studio .NET offers three different levels of extensibility:
- Visual Studio .NET Macros (VSMacros)
- Add-ins and wizards
- Visual Studio Integrator Program (VSIP)
VSMacros are the easiest way to extend the IDE with code. Not only do they provide a big productivity boost by allowing you to record several actions in the IDE and play them back as a single command, they also allow you to learn the Visual Studio .NET Automation Model while recording macros. VSMacros also offer a full-fledged development environment called the Macros IDE that is based on the Visual Studio .NET IDE. It uses the Visual Basic .NET language and is used for macro editing and debugging. For more information about macros, see Automating Repetitive Actions by Using Macros.
Add-ins and Wizards
Add-ins are time- and labor-saving applications that attach to and are used within the IDE. They are COM objects that implement the IDTExtensibility2 Interface and communicate with the IDE through the automation object model contained in the EnvDTE type library (dte.olb). Programming languages can also add additional automation object through their own type libraries. Because Add-ins are compiled, binary code, your intellectual property is protected. You can implement Add-ins in any COM-consuming language such as Visual C++ .NET, Visual Basic .NET, Visual C# .NET, and so forth.
Add-ins are preferable to VSMacros when you want to create entire new features in the environment that fit seamlessly as a part of the Visual Studio .NET IDE. Add-ins also allow you to accomplish other tasks that macros cannot:
- Create custom property pages for the Options dialog box on the Tools menu. For more information, see Creating Custom Tools/Options Pages.
- Create tool windows that act just like Visual Studio .NET tool windows. For more information, see Creating and Controlling Tool Windows.
- Dynamically enable and disable named commands on menus and the Command bar. For more information, see Adding and Handling Commands.
- Add contact and descriptive information to the Visual Studio .NET Help About box.
Wizards are automation tools that lead a user step-by-step through a series of actions to accomplish a complex or difficult task. Wizards are created using the IDTWizard Interface, and are invoked through the New Project or New File dialog boxes.
Visual Studio Integrator Program (VSIP)
For the majority of users, macros, Add-ins, and wizards meet most of their needs in Visual Studio .NET. Some users, however, need to go beyond the considerable capabilities of the Visual Studio automation model. For example, a user might want to incorporate a new programming language into the Visual Studio .NET IDE, possibly creating a need for:
- A new project type.
- A customized editor.
- Advanced debugging features.
The Visual Studio Integrator Program, or VSIP, was created so you can accomplish this. VSIP provides you with the tools and information you need to integrate your products into the Visual Studio .NET environment. VSIP, which is a collection of SDKs, is a developer suite and platform that gives VSIP partners finer and more extensive control over the environment by providing access to more interfaces and full Visual Studio .NET Help integration. With VSIP, partners are able to provide greater functionality in their users' design environment. For more details about VSIP, see http://msdn.microsoft.com/vstudio/vsip/default.asp.
Selecting Which Automation Approach to Use
If you are not sure which automation project type to use, consider the following factors.
Do you want to distribute the code?
- Distribute the code - you can use a macro. You can deploy a macro by copying the macro project files to the new location, without setup or registration. For details, see Recording Macros.
- Distribute a compiled application - use an add-in or a wizard. Add-ins and wizards protect your intellectual property through compilation, but have the addition overhead of a deployment project. For details, see Creating an Add-In or Creating a Wizard.
What programming language do you want to use to develop your automation application?
- Visual Basic - You can create macros, add-ins, or wizards.
- Other languages - You can create add-ins and wizards, using the IDTExtensibility2 Interface and the IDTWizard Interface.
Does the task require user input?
- No user input is needed - A macro or add-in would be suitable.
- Simple input - A macro, add-in, or wizard would be suitable.
- Complex input - If the input has many steps or requires verification, a wizard may be most appropriate.
How complicated is the task you are automating?
- Very simple - If you can accomplish your task in just a few lines of code, a macro would be appropriate.
- Complicated - While macros can include forms, references, and classes, an add-in or wizard might be more appropriate.
How do you think your user will start your application?
- Menus or command bars - You can use an add-in.
- A keyboard shortcut or the Macro Explorer - You can use a macro.
- New Project or New Item menu item - Using a wizard is typical for adding a new project or file to an application.
What's the lifetime of your application?
- I just need it for today - A recorded macro may be sufficient.
- I'll be using it long term - The macro, wizard, and add-in are all suitable.
What do you need to develop?
- An automated task - Macros, add-ins, and wizards can all be used to automate tasks.
- Custom property pages for the Tools, Options dialog box - Add-ins support this functionality.
- Custom tool window - Add-ins support this functionality.
- A new project type - Become a VSIP partner.
- Support for a new programming language in .NET - Become a VSIP partner.