Condividi tramite


Extending the Isolated Shell

You can extend the Visual Studio isolated shell by adding a VSPackage, a Managed Extensibility Framework (MEF) component part, or a generic VSIX project to your isolated shell application.

Note

The following steps presuppose that you have created a basic isolated shell application by using the Visual Studio Shell Isolated project template. For more information about this project template, see Walkthrough: Creating a Basic Isolated Shell Application.

Locations for the Visual Studio Package Project Template

The Visual Studio Package project template can be found in three different locations in the New Project dialog:

  1. Under Visual Basic Extensibility. The default language of the project is Visual Basic.

  2. Under C# Extensibility. The default language of the project is C#.

  3. Under Other Project Types Extensibility. The default language of the project is C++.

Adding a VSPackage

You can add a VSPackage to your isolated shell application. The following steps show how to add a new VSPackage that adds menu commands.

To add a new VSPackage

  1. Create a Visual Studio Package project and name the project MenuCommandsPackage.

  2. On the first page of the Visual Studio Package template, click Next. On the next page, select Visual C# and then click Next.

  3. On the Basic VSPackage Information page, set Company name to Fabrikam and VSPackage name to FabrikamMenuCommands, and then click Next.

  4. On the next page, select Menu Command and then click Next.

  5. On the next page, set Command name to Fabrikam Command, and Command ID to cmdid FabrikamCommand, and then click Next.

  6. On the Select Test Project Options page, clear the test options, and then click Finish.

    The template creates a project named MenuCommandsPackage, which appears in Solution Explorer.

  7. In the ShellExtensionsVSIX project, open the Source.extension.vsixmanifest file. Edit this file in the Design view, not the Code view.

    The Content section should contain one entry for the VSShellStub.AboutBoxPackage project.

  8. Click Add Content.

  9. In the Add Content window, in the Select a content type list, select VS Package.

  10. In Select a source, Project should be selected. In the list box, select MenuCommandsPackage.

  11. Save and close the file.

  12. Rebuild the solution and start debugging the isolated shell.

  13. On the Tools menu, click Fabrikam Command.

    A message box should appear.

  14. Stop debugging the application.

Adding a MEF Component Part

The following steps show how to add a MEF component part to your isolated shell application.

To add a MEF component

  1. In the Add New Project dialog box, select Visual C# and then select Extensibility. Select the Editor Margin project template. Name the project ShellEditorMargin.

  2. In the ShellExtensionsVSIX project, open the Source.extension.vsixmanifest file. Edit this file in the Design view, not the Code view.

  3. In the Content section, click Add Content.

  4. In the Add Content window, in the Select a content type list, select MEF Component.

  5. In Select a source, the Project option should be selected. In the list box, select ShellEditorMargin.

  6. Save and close the file.

  7. Rebuild the solution and start debugging the isolated shell.

  8. Open a text file.

    A green margin that contains the words "Hello world!" should be displayed at the bottom of the text file window.

  9. Stop debugging the application.

Adding a Generic VSIX Project

To add a generic VSIX project

  1. In the Add New Project dialog box, select Visual C# and then select Extensibility. Select the VSIXProject project template. Name the project EmptyVSIX.

  2. In the ShellExtensionsVSIX project, open the Source.extensions.vsixmanifest file. Edit this file in the Design view, not the Code view.

  3. In the Content section, click Add Content.

  4. In the Add Content window, in the Select a content type list, select the kind of content you want to add.

  5. In Select a source, the Project option should be selected. In the list box, select the name of your VSIX project.

  6. Save and close the file.

  7. If this project includes compiled code, you must edit the project to include the assembly in the output.

    1. Unload the VSIX project and open the project file for editing.

    2. In the first <PropertyGroup> block, change the value of <CopyBuildOutputToOutputDirectory> to true.

    3. Save and reload the project.

  8. Build and run the solution.

See Also

Tasks

Walkthrough: Creating a Basic Isolated Shell Application