Chapter 8. Automation, Macros, and Add-ins

Once you have been working with VS.NET for a while, you will discover that you often perform certain tasks over and over. The particular tasks you need to perform will be very dependent on how you are using the IDE, what language and project types you deploy, and your own development style (or the development guidelines under which you are working). This chapter is all about how to get the IDE to automate these activities, by writing either macros or add-ins.

A macro is a snippet of VB.NET code that automates some operation in VS.NET. Macros provide a quick and easy way to automate tasks. They are straightforward to create, because VS.NET has built-in macro creation and editing features.

Macros are fairly powerful, but they have their limits, so VS.NET supports a more flexible if somewhat more complex integration interface for building add-ins. Add-ins are COM components, which means that they take more effort to createyou must compile and install add-ins before you can use them. (Macros can be written and executed on a whimVS.NET compiles them automatically, and they do not need to be installed.) However, as well as having access to a more powerful API than macros, add-ins offer some further advantagesadd-ins are easier to redistribute than macros are, and there is also no danger that anyone using your add-in might inadvertently break it when using VS.NET's macro editor.

If you are writing functionality that you want to distribute outside of your organization, an add-in is the way to go. It allows tighter integration with the IDE, plus allows you to add information to the VS.NET About dialog. However, even add-ins are not the most powerful integration mechanism VS.NET has to offerpackages allow even deeper integration. See Chapter 10 for more details.