How to: Create a .vsct file
Applies to: Visual Studio Visual Studio for Mac
Note
This article applies to Visual Studio 2017. 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 article explains how to manually create a new .vsct file.
To manually create a new .vsct file
Start Visual Studio.
On the File menu, point to New, and then click File.
In the Templates pane, click XML File and then click Open.
On the View menu, click Properties to display the properties of the XML file.
In the Properties window, click the Browse button on the Schemas property.
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.
In the XML file, type <CommandTable and then press Tab. Close the tag by typing >.
This action creates a basic .vsct file.
Fill in the elements of the XML file that you want to add, according to the VSCT XML schema reference. For more information, see Author .vsct files.
How to: Create a .vsct File from an existing .ctc file
You can create an XML-based .vsct file from an existing command table .ctc source file. By doing this, you can take advantage of the new XML-based Visual Studio command table (VSCT) compiler format.
To create a .vsct file from a .ctc file
Obtain a copy of the Perl language.
Obtain a copy of the Perl script ConvertCTCToVSCT.pl, typically located in the <Visual Studio SDK installation path>\VisualStudioIntegration\Tools\bin folder.
Obtain a copy of the .ctc source file that you want to convert.
Place the files in the same directory.
In the Visual Studio command prompt window, navigate to the directory.
Type
perl.exe ConvertCTCtoVSCT.pl PkgCmd.ctc PkgCmd.vsct
where PkgCmd.ctc is the name of the .ctc file and PkgCmd.vsct is the name of the .vsct file that you want to create.
This action creates a new .vsct XML command table source file. You can compile the file by using Vsct.exe, the VSCT compiler, as you would any other .vsct file.
Note
You can improve the readability of the .vsct file by reformatting the XML comments.
How to: Create a .vsct file from an existing .cto file
You can create an XML-based .vsct file from an existing binary .cto file. Doing this allows you to take advantage of the new command table compiler format. This process works even if the .cto file was compiled from a .ctc file. You can edit and compile the .vsct file into another .cto file.
To create a .vsct file from a .cto file
Obtain copies of the .cto file and its corresponding .ctsym file.
Place the files into the same directory as the vsct.exe compiler.
At the Visual Studio command prompt, go to the directory that contains the .cto and .ctsym files.
Type
vsct.exe <ctofilename>.cto <vsctfilename>.vsct -S<symfilename>.ctsym
where <ctofilename> is the name of the .cto file, <vsctfilename> is the name of the .vsct file you want to create, and <symfilename> is the name of the .ctsym file.
This process creates a new .vsct XML command table compiler file. You can edit and compile the file with vsct.exe, the vsct compiler, as you would any other .vsct file.
Compile 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
Open your project file in the editor. If the project is loaded, you must unload it first.
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 toMenus.ctmenu
.If your project contains a .resx file, add an
EmbeddedResource
element that contains aMergeWithCTO
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.Open the package file, usually named <ProjectName>Package.cs or <ProjectName>Package.vb, in the editor.
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.