Visual Studio Extensibility

Microsoft Visual Studio provides multiple ways of extensibility:

  • Packages: packages are the preferred way of extending the IDE. Packages can be created using several languages, managed (C#, VB.NET, Managed C++) or native (C++). A package can provide:
    • New commands and user interface items (toolbars, main menus, context menus, etc.).
    • Reaction to Visual Studio events.
    • New toolwindows (dockable windows like the Solution Explorer).
    • New project types.
    • New project subtypes (“flavors” based on existing project types).
    • New document types.
    • New editors.
    • Integration with Source Code Control systems.
    • New text editing features.
    • New languages.
    • New debugging features.
    • New Data Designer features.
    • Etc.
  • Managed Extensibility Framework (MEF): since Visual Studio 2010, the editor is built by using Managed Extensibility Framework (MEF) components. You can build your own MEF components to extend the editor, and your code can consume editor components as well.
  • Domain-Specific Languages (DSL): using the Modeling SDK for Visual Studio (MSDK), you can create powerful model-based development tools that you can integrate into Visual Studio. As an example, the UML tools are created using MSDK. In the same manner, you can create one or more model definitions and integrate them into a set of tools.
  • Templates: Visual Studio project and item templates provide reusable stubs that give users some basic code and structure that they can use for their own purposes. You can create new project templates that appear in the New Project dialog and new project item templates that appear in the Add Item dialog.
  • Wizards: apart from standalone file-based project templates, you can also either complement them with a wizard (Microsoft.VisualStudio.TemplateWizard.IWizard interface) or create custom wizards (EnvDTE.IDTWizard interface) that appear in the New Project and Add Item dialogs, and that allow complete customization of the solution/project creation or item addition.
  • Visual Studio Shell: if instead of creating a tool that integrates inside the Visual Studio product you need to provide an Integrated Development Environment (IDE) as part of your tool, you can reuse the Visual Studio Shell for your own IDE, with menus, toolwindows, document windows, etc. There are two variants:
    • Visual Studio Shell “Isolated”: Isolated mode allows you to create custom tools that run side-by-side with other versions of Visual Studio. It is intended primarily for tools that can access Visual Studio services without depending on all the standard Visual Studio features. You can customize the appearance of applications built on the Visual Studio isolated shell. You can easily turn off the features and menu command groups that you do not wish to appear together with your application.
    • Visual Studio Shell “Integrated”: Integrated mode enables your users to use standard Visual Studio features along with your custom tools. The integrated shell is intended primarily for hosting programming languages and software development tools.
  • .NET Compiler Platform (formerly “Roslyn”): before the .NET Compiler Platform extensions had to use the code model provided by automation (EnvDTE.Project.CodeModel, EnvDTE.ProjectItem.FileCodeModel) which had limitations and inaccuracies parsing or modifying source code. The .NET Compiler Platform exposes to extensions the compiler APIs that Visual Studio uses for the C# and VB.NET languages. Requires Visual Studio 2015.
  • MSBuild: Visual Studio uses the MSBuild project file format to store build information about managed projects. Visual Studio uses a hosted instance of MSBuild to build managed projects, meaning that a managed project can be built in Visual Studio and from the command line (even without Visual Studio installed), with identical results. The Visual Studio build process is defined by a series of MSBuild .targets files that are imported into your project file. One of these imported files, Microsoft.Common.targets, can be extended to allow you to run custom tasks at several points in the build process.
  • Add-ins (removed in Visual Studio 2015): add-ins were a high-level way of extending the IDE. They are deprecated in Visual Studio 2013 and will be removed in the next version. If you start Visual Studio extensibility today, you should start with packages (and if you have already created an add-in, you should convert it to a package).
  • Macros (removed in Visual Studio 2012): macros could be recorded or you could code them by hand with the Macros Editor (“Tools”, “Macros”, “Macros IDE…”). Creating them was easy and quick, but macros couldn’t create forms for data input and their code was visible to the end users. They were removed in Visual Studio 2012.

VS SDK, packages, add-ins, macros and more…