Freigeben über


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

In Part 1, I provided a brief overview of what VSCT looks like and some of the obvious advantages of it over the CTC format.

Availability

As was mentioned earlier, the VSCT format has replaced CTC in all the VSIntegration samples starting with the Visual Studio SDK targeting "Orcas" Beta 1. This also includes the Visual Studio Package wizard output, so any new packages you create will be based on VSCT for their menu items.

Of course, if you have existing CTC that you still need to use, we still have the build tasks and CTC compiler in the SDK.

What about Visual Studio 2005 (Whidbey)?

Since VSCT and CTC both compile down to the CTO format, it is possible to use VSCT in a package designed for Visual Studio 2005! I was going to write up instructions for this, but it looks like Dmitry Pavlov has beet me to the punch. He walks you through converting the C# Reference.MenuAndCommands sample in the VS 2005 SDK to use VSCT. You should be able to follow a similar process for your package.

Converting an existing CTC to VSCT

There is a Perl script to convert CTC files into the new VSCT format called ConvertCTCtoVSCT.pl. This also shipped in the Visual Studio 2005 SDK Version 4.0 in the Prerelease folder with the VSCT compiler.

[On a side note, we had a forehead-slapping moment recently when we realized that this perl script didn't ship in the first version of the VSSDK targeting "Orcas". Whoops. (The cause of this was because we restructured our setup scripts that actually build the VSSDK to conform to the same system that is used for the rest of Visual Studio. We missed this file and a few others in the conversion process.) We also missed the XSD (Xml Schema) file that gives you intellisense when you're editing VSCT files. Double Whoops. Never fear though, these files will be included in the next CTP for Orcas, and if you really need them, you can just copy them out of the VS 2005 SDK Version 4.0.]

If you think Perl is something that you would give your mom for her birthday, there is an alternate way to convert a CTC file. VSCT.exe actually is both a compiler and decompiler for the CTO format. In other words, you can decompile from CTO (that was original compiled with CTC.exe) into VSCT using the VSCT compiler! You don't even have to specify that you're decompiling since VSCT.exe figures this out for you. This is the approach that Dmitry takes in the blog post mentioned earlier.

Embedding Image Resources in a CTO

One of the slightly annoying aspects of CTC is the way that images work. In many cases, you will want a custom bitmap for a command that your package exposes. Traditionally, you would specify a resource ID in your CTC file. When Visual Studio is setting up your menu commands, it would then look into your package (or satellite) DLL and extract the resource. This usually works, but can be error-prone and tough to debug under some circumstances.

VSCT works around this by allowing you to embed images directly into the CTO. This avoids VS having to do the extra resource lookup when your commands are merged and is a more reliable way to specify command images. The trick here is to use the href attribute for the <Bitmap /> tag in the VSCT file. The C# Reference.MenuAndCommands sample in the Orcas version of the VSSDK demonstrates embedding images in a CTO:

<Bitmap guid="guidGenericCmdBmp" href="GenericCmd.bmp" usedList="bmpArrow" />

Comments

  • Anonymous
    May 11, 2007
    Hi Aaron,I just did not have an opportunity to wait because I had to get it to work then. Hope it's alright.
  • Anonymous
    May 11, 2007
    Hey Dmitry,Of course it's alright...in fact it's GREAT to see you (or others) posting about VS extensibility! Thanks for posting instructions on this....it's something that many people have been asking us about.Thanks again,Aaron
  • 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
    Updated link - vsx-insider.blogspot.com/.../adding-vsct-compilation-support-to.html