Share via


How to: Create a .Vsct File

Note

This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

There are several ways to create an XML-based Visual Studio Command Table configuration (.vsct) file.

  • You can create a new VSPackage in the Visual Studio Package Template.

  • You can use the XML-based command table configuration compiler, Vsct.exe, to generate a file from an existing .ctc file.

  • You can use Vsct.exe to generate a .vsct file from an existing .cto file.

  • You can manually create a new .vsct file.

    This topic explains how to manually create a new .vsct file.

To manually create a new .vsct file

  1. Start Visual Studio.

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

  3. In the Templates pane, click XML File and then click Open.

  4. On the View menu, click Properties Window to display the properties of the XML file.

  5. In the Properties window, click the Browse (…) button on the Schemas property.

  6. In the list of XSD schemas, select the vsct.xsd schema. If it is not in the list, click Add and then find the file on a local drive. Click OK when you are finished.

  7. In the XML file, type <CommandTable and then press TAB. Close the tag by typing >.

    This creates a basic .vsct file.

  8. Fill in the elements of the XML file that you want to add, according to the VSCT Schema. For more information, see Authoring .Vsct Files

Compiling the Code

Simply adding a .vsct file to a project does not cause it to compile. You must incorporate it in the build process.

To add a .vsct file to project compilation

  1. Open your project file in the editor. If the project is loaded, you must unload it first.

  2. Add an ItemGroup element that contains a VSCTCompile element, as shown in the following example.

    <ItemGroup>  
      <VSCTCompile Include="TopLevelMenu.vsct">  
        <ResourceName>Menus.ctmenu</ResourceName>  
      </VSCTCompile>  
    </ItemGroup>  
    
    

    The ResourceName element should always be set to Menus.ctmenu.

  3. If your project contains a .resx file, add an EmbeddedResource element that contains a MergeWithCTO element, as shown in the following example.

    <EmbeddedResource Include="VSPackage.resx">  
      <MergeWithCTO>true</MergeWithCTO>  
      <ManifestResourceName>VSPackage</ManifestResourceName>  
    </EmbeddedResource>  
    
    

    This markup should go inside the ItemGroup element that contains embedded resources.

  4. Open the package file, usually named ProjectNamePackage.cs or ProjectNamePackage.vb, in the editor.

  5. Add a ProvideMenuResource attribute to the package class, as shown in the following example.

    [ProvideMenuResource("Menus.ctmenu", 1)]  
    

    The first parameter value must match the value of the ResourceName attribute you defined in the project file.

See Also

Authoring .Vsct Files
Visual Studio Command Table (.Vsct) Files
How to: Create a .Vsct File from an Existing .Ctc File
How to: Create a .Vsct File from an Existing .Cto File
VSCT XML Schema Reference