Automation Samples for Visual Studio .NET 2002


Microsoft has invested heavily in Visual Studio .NET extensibility. This is an important part of Visual Studio .NET because it lets customers easily tailor the tool to their personal working style and enables them to accommodate team practices. You can simply capture several steps in a regular process (for example, for check-ins, creating new projects or forms, or updating code) and make that process available as a single command to invoke. Independent software vendors (ISVs) can implement entirely new features (including groupware, profiling tools, work flow, or life-cycle tools) that fit into Visual Studio .NET as seamlessly as if they were built into the shipping Visual Studio .NET product.

This download site contains many key samples that show you how to build VSMacros projects, add-ins, and wizards to make your teams more productive and to bend Visual Studio .NET to the ways you like to work. Look for more samples, as well as some white papers and overview documents, in the future.

All of these samples use the Visual Studio automation model, which is free and publicly distributed with Visual Studio .NET. The Visual Studio .NET automation model is four to five times richer and more powerful than any automation model that shipped with a previous version of Visual Studio. With this new automation model, you can do the following:

  • Intercept commands when they are invoked, and either provide preprocessing or implement the command yourself.
  • Control the solution, projects, and project items by adding or removing them.
  • Control the build configurations mechanisms and hook various build events.
  • Control a large portion of the text editor.
  • Implement commands that help you debug with the debugger objects.
  • Control the Windows Forms Designer more easily and with more power than with what Visual Basic 6.0 offered over the Visual Basic Forms Designer.
  • Customize the deployment and packaging projects
  • Create tool windows that behave just like the built-in tool windows for docking and floating.
  • Provide content to the Property Browser when items are selected in tool windows.
  • Control several of the built-in tool windows (including Task List, Toolbox, Command Window, and Output Window).
Keybindings Table Add-In
Written in Microsoft Visual C++® .NET, this add-in puts a Keybindings command in the Help menu that is similar to the Visual C++ 6.0 Keyboard Map Help command.
PrePostBuildRules Add-In

This add-in has been written in both Microsoft Visual C# .NET and Microsoft Visual Basic® .NET. It provides pre- and post-build rules at the solution and project levels for projects that implement the common Visual Studio automation model.

EventWatcher Add-In
The EventWatcher Add-in connects to all the core shell event objects. As each event is fired, a message box displays information about arguments passed to that event. This add-in has been written in Visual Basic .NET, Visual C# .NET, and Visual C++ .NET.
Windows Forms Automation Add-In
Written in Visual Basic .NET, this sample demonstrates how to work with the object model provided by the Windows Forms Designer. The add-in creates a new Windows Application project, and then it uses the object model to build a form.
WSH Script (Microsoft JScript®)
The WSH Script sample demonstrates how to use Windows Script Host to launch Visual Studio. The sample creates an instance of Visual Studio and adds a task item. To use this sample, double-click it from Microsoft Windows® Explorer, or type wsh-vs.js at a Windows command prompt.
ScriptHost Add-In
Written in Visual C++, the ScriptHost sample hosts the Visual Basic Scripting Edition (VBScript) engine and allows you to run VBScript macros from Visual C++ 6.0 in the Visual Studio .NET integrated development environment (IDE). You do not need to make any syntactic changes to your code except for method and property calls that are not available in Visual Studio .NET.
Web App Provider Add-In
Written in Visual C++, this sample allows you to upload your Web site from the Visual Studio .NET Start page to a Web hoster.
Simple Add-Ins
This add-in displays a message box as each member of IDTExtensibility2 is called. It also adds a button to the Tools menu; when clicked, the button displays a message. The button is added using the Microsoft Office CommandBars rather than the new AddNamedCommand method. This add-in has been written in Visual Basic .NET, Visual C# .NET, and Visual C++ .NET.
RegExplore
Written in Visual C++, this add-in emulates the Registry Editor as a tool window within the environment. Some of the object model functionality demonstrated includes:
  • Add-in
  • ToolsOptions page
  • ToolsOptions properties
  • Using the StatusBar
  • Adding tasks (with a custom image)
  • Adding items to the toolbox
  • Surfacing an object model through an add-in
  • Creating a Satellite DLL
  • Loading the Satellite DLL and loading resources from it
  • Creating tool windows
  • Dynamically adding commands
  • Pushing properties to the Property Browser
  • Creating named commands
Resource Editor for .resx Files
You can open this C#-based add-in on .resx files to edit the resources.
Command Browse Add-In
Written in Visual Basic .NET, the Command Browse (CmdBrowse) add-in walks the command bar structure in the environment, displaying the GUID/ID pair of each command, along with its named command. This information is useful when working with the Office CommandBar object model.
GenerateHTML
Written in Visual C++, the GenerateHTML add-in takes the current selection in the text editor and generates color-coded HTML for including in a Web page.
Thumbnails Add Item Wizard
Written in Visual Basic .NET, this wizard prompts for a directory of JPEG files, adds an HTML page to your project, crunches all of the JPEGs down to thumbnails (by using .NET image classes) and lays them out on the HTML page.
Add-in Wizard
This application wizard creates a couple of projects, adds items to the projects, uses Find automation to edit templates, uses the editor object model, and so on. Written in Visual C++ .NET, this is a version of the source code for the Visual Studio Add-in Wizard found in the product.
Spell Check Macro
This macro project performs spell-checking by using Microsoft Word components and a user interface based on Visual C# .NET Windows Forms.
Outlook Tasks
This macro project fetches Microsoft Outlook® tasks and puts them in the Visual Studio Task List. It then keeps those tasks synchronized between Visual Studio and Outlook whenever you change task descriptions or mark tasks complete.
Solution Extender Add-in
This sample demonstrates the use of Automation Extenders to "extend" existing Visual Studio objects with new properties and methods. You can extend property grid display objects as well as automation objects, so that more methods and properties are available to the caller. This sample extends both the Solution property grid display object as well as the DTE.Solution automation object. The sample has been written in C# and Visual Basic .NET.
Unsupported Tools
This archive contains unsupported tools to be used with the Visual Studio object model. The following items are currently available:
  • ExtBrws.dll. To use ExtBrws.dll, run regsvr32 on the dll, then load it from the Visual Studio or Visual Basic for Applications Add-in Manager dialog box. Click the item on the Tools menu to bring up a dialog box that displays all of the late-bound objects available under DTE, DTE.Events, or DTE.Properties.
  • GenerateIcoData.exe. Add-ins can provide information in the VS .NET Help About dialog. To do this, you need to register some information including some icon binary data. You can run this utility to generate the icon binary data you need to put in the registry.
Command Browse Add-In
Written in Visual Basic .NET, the Command Browse (CmdBrowse) add-in walks the command bar structure in the environment, displaying the GUID/ID pair of each command, along with its named command. This information is useful when working with the Office CommandBar object model.
Custom Bitmap Add-In
Written in Visual Basic .NET and Visual C# .NET, this sample demonstrates the use of custom bitmaps when adding a named command to the Tools menu through an add-in.
Intellidoc Add-In
This add-in, written in Visual C# .NET, is a near duplicate implementation of the Build Comment Web Pages features in Visual Studio .NET. It uses the Visual Studio Code Model, text editor object model, and common project object model.
Wizard in Visual C# Add-In
This application wizard, written in Visual C# .NET, is a near duplicate of the Add-in Wizard found in the new project dialog box under Other Projects and Extensibility Projects. It adds projects to the solution, items to projects, and uses the Find and text editor object models.
Custom Wizard Add-In
This wizard, written in Visual C# .NET, demonstrates all the context parameterss passed into Add Item, Add Project, and Add SubProject wizards. If you add custom parameters to your wizard's .vsz files, the add-in will display those custom parameters so that you can see how they are passed into the wizard.
XSL Wizard Add-In
This sample creates a wizard that lets you add a template in the Add New Item/Local Project Items dialog box to create XML and XSL files. The sample code is available in Visual Basic .NET, Visual C++ .NET, and Visual C# .NET.
ToolWindow Add-Ins
Written in Visual C# .NET, Visual Basic .NET, and Visual C++ .NET, these add-ins demonstrate how to create tool windows.