Udostępnij za pośrednictwem


CTC is dead...Long Live VSCT! (Part 1)

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:

BUTTONS_BEGIN
// 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";
BUTTONS_END

 

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:

    <Buttons>
      <!--
      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"/>
        <Strings>
          <ButtonText>C# Sample Graph Command</ButtonText>
        </Strings>
      </Button>
      <Button guid="guidMenuAndCommandsCmdSet" id="cmdidMyZoom" priority="0x100" type="Button">
        <Parent guid="guidMenuAndCommandsCmdSet" id="MyToolbarGroup"/>
        <Icon guid="guidOfficeIcon" id="msotcidZoom"/>
        <Strings>
          <ButtonText>C# Sample Zoom Command</ButtonText>
        </Strings>
      </Button>
    </Buttons>

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.

Comments

  • Anonymous
    April 10, 2007
    Hi Aaron,Thank you for the interesting information! XML format is of course more preferable for .NET developers (and maybe even for our C++ colleagues) than the pseudo-C++ format of CTC. As I understand VSCT.xsd is the scheme describing .vsct file structure.For CTC there is an MSBuild task in Microsoft.VsSDK.Build.Tasks.dll assembly which is presented in Microsoft.VsSDK.targets file. This allows us to compile CTC easy.Is VS SDK team going to add such support for compiling .vsct files in next VS SDK versions?Thanks,
  • Anonymous
    April 10, 2007
    Hi Dmitry,I will be posting more detail on our plans for fully supporting VSCT in the next few days. In short, we will be fully supporting this in the next release of the VSSDK targetting Visual Studio Orcas. I will also post details on your options for compiling VSCT from a csproj file in Whidbey (VS 2005).Thanks,Aaron
  • Anonymous
    April 10, 2007
    Thanks Aaron! That would be really great!
  • Anonymous
    April 27, 2007
    We've just released a version of the Visual Studio SDK that targets Visual Studio "Orcas" Beta 1 . You
  • Anonymous
    May 09, 2007
    Hi Aaron,I have integrated the VSCT compilation into Whidbey's project myself. That solution allows compiling extensibility projects developed with VS SDK 4.0 RTM. Detailed description of how to add VSCT compilation support to Whidbey (VS 2005) projects can be found here:http://blog.neutron.sharpstyle.com/2007/05/09/adding-vsct-compilation-support-to-whidbey-vs-2005-projects/Thanks,
  • Anonymous
    May 11, 2007
    In Part 1 , I provided a brief overview of what VSCT looks like and some of the obvious advantages of
  • Anonymous
    May 15, 2007
    Aaron Marten from the VS SDK team has a couple of posts on the new VSCT technology that replaces CTC
  • Anonymous
    May 16, 2011
    sharpstyleneutron.wordpress.com/.../adding-vsct-compilation-support-to-whidbey-vs-2005-projectsvsx-insider.blogspot.com/.../adding-vsct-compilation-support-to.html