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.
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" />