Search code examples
visual-studio-2015vs-extensibility

Visual Studio Extensibility Menu issue


I have been playing around Visual Studio Extensibility and trying Menu sample. I have gone through MSDN material to understand Visual Studio Command Table but still struggling to understand its structure. With following sample I wish to add new Menu item called "Dump" under "Help" Menu. Project compiles fine however new menu item is not shown under "Help" menu. There is some obvious thing which I am missing but couldn't figure out what it is. Any help in this regard is highly appreciated. CommandTable xml is as follows.

<?xml version="1.0" encoding="utf-8"?>
<CommandTable xmlns="http://schemas.microsoft.com/VisualStudio/2005-10-18/CommandTable" xmlns:xs="http://www.w3.org/2001/XMLSchema">
   <Extern href="stdidcmd.h"/>
   <Extern href="vsshlids.h"/>
   <Commands package="guidTestCommandPackage">
   <Groups>
     <Group guid="myCommandSet" id="NewMenuGroup" priority="0x0100">
       <Parent guid="guidSHLMainMenu" id="IDM_VS_MENU_HELP"/>
     </Group>
   </Groups>

  <Menus>     
    <Menu guid="myCommandSet" id="DumpMenu" priority="0x700" type="Menu">
      <Parent guid="myCommandSet" id="NewMenuGroup"/>
      <Strings>
        <ButtonText>Dump</ButtonText>
        <CommandName>Dump</CommandName>
      </Strings>
    </Menu>
  </Menus>

  <Bitmaps>
    <Bitmap guid="guidImages" href="Resources\TestCommand.png" usedList="bmpPic1, bmpPic2, bmpPicSearch, bmpPicX, bmpPicArrows, bmpPicStrikethrough"/>
  </Bitmaps>
 </Commands>

  <Symbols>
   <GuidSymbol name="guidTestCommandPackage" value="{2eb800ad-4b09-497c-98bb-a6a2ea8040b8}" />

   <GuidSymbol name="myCommandSet" value="{368F5466-4D1A-4430-AFBD-A76B6BC95FF8}">
     <IDSymbol name="NewMenuGroup" value="0x0125"/>
     <IDSymbol name="DumpMenu" value="0x0126"/>
   </GuidSymbol>

   <GuidSymbol name="guidImages" value="{9afb3053-51d3-43a8-8225-01fc85c89f9a}" >
     <IDSymbol name="bmpPic1" value="1" />
     <IDSymbol name="bmpPic2" value="2" />
     <IDSymbol name="bmpPicSearch" value="3" />
     <IDSymbol name="bmpPicX" value="4" />
     <IDSymbol name="bmpPicArrows" value="5" />
     <IDSymbol name="bmpPicStrikethrough" value="6" />
   </GuidSymbol>
 </Symbols>
</CommandTable>

Solution

  • You need to define a Button element, that's the element that the user interacts with.

    The simplest fix for your issue is to replace this XML:

    <Menus>
      <Menu guid="myCommandSet" id="DumpMenu" priority="0x700" type="Menu">
        <Parent guid="myCommandSet" id="NewMenuGroup"/>
        <Strings>
          <ButtonText>Dump</ButtonText>
          <CommandName>Dump</CommandName>
        </Strings>
      </Menu>
    </Menus>
    

    with the following XML.

    <Buttons>     
      <Button guid="myCommandSet" id="DumpMenu" priority="0x700" type="Button">
        <Parent guid="myCommandSet" id="NewMenuGroup"/>
        <Strings>
          <ButtonText>Dump</ButtonText>
          <CommandName>Dump</CommandName>
        </Strings>
      </Button>
    </Buttons>