One of the pieces of feedback we’ve gotten for a while now around creating a Visual Studio Package is the difficulty of working with the CTC format. This is the pseudo-C++ file that you use to specify what menus/groups/buttons/etc… your VSPackage provides or responds to. You also can specify things like default keyboard bindings and graphics for the commands.
CTC versus VSCT
Here is a short bit of CTC from the C# Reference.MenuAndCommands sample in Visual Studio SDK Version 4.0 that declares two menu items to add:
// Here there is the definition of the commands placed inside the toolbars. Notice that there is
// no difference between these toolbar button definitions and the menu item definition above.
guidMenuAndCommandsCmdSet:cmdidMyGraph, guidMenuAndCommandsCmdSet:MyMainToolbarGroup, 0x100, guidOfficeIcon:msotcidGraph, BUTTON, , “C# Sample Graph Command”;
guidMenuAndCommandsCmdSet:cmdidMyZoom, guidMenuAndCommandsCmdSet:MyToolbarGroup, 0x100, guidOfficeIcon:msotcidZoom, BUTTON, , “C# Sample Zoom Command”;
The successor to CTC is an XML-based format called VSCT. Functionally, they are equivalent, but VSCT is (and will continue to become) far easier to work with than CTC. Here is the equivalent of the above in VSCT:
Here there is the definition of the commands placed inside the toolbars. Notice that there is
no difference between these toolbar button definitions and the menu item definition above.
<Button guid=“guidMenuAndCommandsCmdSet“ id=“cmdidMyGraph“ priority=“0x100“ type=“Button“>
<Parent guid=“guidMenuAndCommandsCmdSet“ id=“MyMainToolbarGroup“/>
<Icon guid=“guidOfficeIcon“ id=“msotcidGraph“/>
<ButtonText>C# Sample Graph Command</ButtonText>
<Button guid=“guidMenuAndCommandsCmdSet“ id=“cmdidMyZoom“ priority=“0x100“ type=“Button“>
<Parent guid=“guidMenuAndCommandsCmdSet“ id=“MyToolbarGroup“/>
<Icon guid=“guidOfficeIcon“ id=“msotcidZoom“/>
<ButtonText>C# Sample Zoom Command</ButtonText>
Part of the problem with CTC is that you never quite know what the next field is, especially if you delete a line of comments that stated the field order. Here, since VSCT is based on self-describing XML, it’s very clear on what the various values associated with these buttons mean.
State of VSCT
Because Visual Studio 2005 was built using CTC to define all of its commands, Microsoft officially does not support packages compiled using VSCT on Visual Studio 2005. However, since Visual Studio 2005 SDK Version 1.0, we have actually been shipping the VSCT compiler in the SDK! You can check it out in the “Prerelease” folder. Even though this is officially unsupported, there are no known incompatibilities between Visual Studio 2005 and the output from the VSCT compiler (.cto file).
Continue on to Part 2 for some tips on converting your existing CTC files to VSCT.