How to: Create VSPackages (C# and Visual Basic)

The Visual Studio Integration Package Wizard creates a basic implementation of a simple VSPackage given the company name, the VSPackage name, and the VSPackage version number. The wizard can add code to create a simple menu command, a tool window, or a custom editor.

To create a VSPackage by using the Visual Studio Integration Package Wizard

  1. On the File menu, point to New, and then click Project.

  2. In the New Project dialog box, expand Other Project Types, and then click Extensibility.

  3. In the Templates pane click Visual Studio Integration Package.

  4. In the Location box, type the file path for your VSPackage.

  5. In the Name box, type the name for the solution and then click OK to start the wizard.

    On the Select a Programming Language page, select either Visual C# or Visual Basic. Have the wizard generate a key.snk file to sign the assembly. Alternatively, Browse to your own key file. The wizard makes a copy of your key file and names it key.snk.

    1. Specify details about your VSPackage in the Basic VSPackage Information page. This information is written into the system registry. It can also appear in the Help About dialog box and on the Visual Studio splash screen. For more information, see VSPackage Branding.

    2. Click Next to specify options for your VSPackage, or click Finish to create a basic VSPackage.

  6. Select the Menu Command option to create a new command for your VSPackage. The new command is put at the top of the Tools menu. When the Menu Command option is selected, the Command Options page is displayed after you click Next.

    1. Type the name for the new menu command in the Command Name box.

      If you later want to host the command as a button on the toolbar, the name is also the button's tooltip.

    2. Type the command ID for your menu command in the Command ID text box.

      The command ID is the name of a constant that represents this menu command in the generated code.

    3. Click Next to select test project options for your VSPackage, or click Finish to create a basic VSPackage.

  7. Check the Integration Test Project (C#) check box to create a test project for your solution.

  8. Click Finish to create your VSPackage in the folder that you specified.

To test your menu command

  1. Build the solution, and then start the experimental build of Visual Studio by pressing F5.

  2. On the Tools menu, click your command. A message appears with the following text:

    <VSPackage name>,

    Inside vsip.<Project name>.<VSPackage name>.Exec().

Compiling the Code

Projects generated with the wizard have embedded paths that refer to utilities like Regpkg.exe. To use them on another computer, you must make sure that the paths are valid.

See Also

Other Resources