C
C#4mo ago
Aztic

✅ Menus and Submenus in VSIX Extensions

I'm quite new with extension development and i'm stuck in what is seems to be a simple element but i can't figure out what i'm missing. I'm trying to accomplish a menu (submenu?) to put all commands of the extension like some already do (like aws toolkit, codemaid, etc). But no matter what i do, the commands are displayed just as a separated commands This is the content of my vsct file
<?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="guidSandboxVsixPackage">

<Groups>
<Group guid="guidSandboxVsixPackageCmdSet" id="MyMenuGroup" priority="0x100">
<Parent guid="guidSHLMainMenu" id="IDM_VS_MENU_TOOLS" />
</Group>
</Groups>

<Buttons>
<Button guid="guidSandboxVsixPackageCmdSet" id="TestCommandId" priority="0x0100" type="Button">
<Parent guid="guidSandboxVsixPackageCmdSet" id="MyMenuGroup" />
<Icon guid="guidImages" id="bmpPic1" />
<Strings>
<ButtonText>Test Command</ButtonText>
</Strings>
</Button>
</Buttons>

<Menus>
<Menu guid="guidSandboxVsixPackageCmdSet" id="MyMenuGroup" priority="0x100" type="Menu">
<Parent guid="guidSHLMainMenu" id="IDM_VS_MENU_TOOLS" />
<Strings>
<ButtonText>Test Menu</ButtonText>
<CommandName>Test Menu</CommandName>
</Strings>
</Menu>
</Menus>

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

<Symbols>

<!-- This is the package guid. -->
<GuidSymbol name="guidSandboxVsixPackage" value="{ecf416eb-b745-4e9f-82b9-18e7032e9a09}" />

<GuidSymbol name="guidSandboxVsixPackageCmdSet" value="{5e67b541-c9e2-459e-8eaf-da5fda34f6ed}">
<IDSymbol name="MyMenuGroup" value="0x1020" />
<IDSymbol name="TestCommandId" value="0x0100" />
<IDSymbol name="MyMenu" value="0x9999" />
<IDSymbol value="4129" name="cmdidTestToolWindow1Command" />
<IDSymbol name="IDM_VS_MENU_EXTENSIONS" value="0x0091" />
</GuidSymbol>

<GuidSymbol name="guidImages" value="{bc41b49b-0ed7-4313-b16e-5d78d5c21357}">
<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>

<GuidSymbol value="{55dea3b6-f9bd-4d6d-8ee7-35505a1d3669}" name="guidImages1">
<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>
<?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="guidSandboxVsixPackage">

<Groups>
<Group guid="guidSandboxVsixPackageCmdSet" id="MyMenuGroup" priority="0x100">
<Parent guid="guidSHLMainMenu" id="IDM_VS_MENU_TOOLS" />
</Group>
</Groups>

<Buttons>
<Button guid="guidSandboxVsixPackageCmdSet" id="TestCommandId" priority="0x0100" type="Button">
<Parent guid="guidSandboxVsixPackageCmdSet" id="MyMenuGroup" />
<Icon guid="guidImages" id="bmpPic1" />
<Strings>
<ButtonText>Test Command</ButtonText>
</Strings>
</Button>
</Buttons>

<Menus>
<Menu guid="guidSandboxVsixPackageCmdSet" id="MyMenuGroup" priority="0x100" type="Menu">
<Parent guid="guidSHLMainMenu" id="IDM_VS_MENU_TOOLS" />
<Strings>
<ButtonText>Test Menu</ButtonText>
<CommandName>Test Menu</CommandName>
</Strings>
</Menu>
</Menus>

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

<Symbols>

<!-- This is the package guid. -->
<GuidSymbol name="guidSandboxVsixPackage" value="{ecf416eb-b745-4e9f-82b9-18e7032e9a09}" />

<GuidSymbol name="guidSandboxVsixPackageCmdSet" value="{5e67b541-c9e2-459e-8eaf-da5fda34f6ed}">
<IDSymbol name="MyMenuGroup" value="0x1020" />
<IDSymbol name="TestCommandId" value="0x0100" />
<IDSymbol name="MyMenu" value="0x9999" />
<IDSymbol value="4129" name="cmdidTestToolWindow1Command" />
<IDSymbol name="IDM_VS_MENU_EXTENSIONS" value="0x0091" />
</GuidSymbol>

<GuidSymbol name="guidImages" value="{bc41b49b-0ed7-4313-b16e-5d78d5c21357}">
<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>

<GuidSymbol value="{55dea3b6-f9bd-4d6d-8ee7-35505a1d3669}" name="guidImages1">
<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>
What i've tried so far: (order or hierarchy) - (tools) -> group -> menu -> command - (tools) -> menu -> group -> command - (tools) -> menu -> command - Making the menu and the group have the same id (the current content: MyMenuGroup) - Making the menu and the group have different ids - Trying different types for the Menu (Menu, MenuController, etc) - Specify different child elements like CommandFlag in the Menu attribute (since they said in the docs that was required) At this point i don't really know what i'm missing. I've also tried to search for examples in this repo but without luck https://github.com/microsoft/VSSDK-Extensibility-Samples Are there any docs / articles that can guide me in the right direction?
GitHub
GitHub - microsoft/VSSDK-Extensibility-Samples: Samples for buildin...
Samples for building your own Visual Studio extensions - microsoft/VSSDK-Extensibility-Samples
No description
No description
1 Reply
Aztic
Aztic4mo ago
I'm not quite sure what steps did i do that made menu appear, but as a reference for other persons or for future me since my memory is shit: 1: Have the menu and group in a different GuidSymbol
<GuidSymbol value="{0C0C3FC7-F094-41A2-AE45-E63428268F53}" name="GuidMenuSet">
<IDSymbol name="TestMainMenu" value="0x1020" />
<IDSymbol name="TestMainMenuGroup" value="0x1021" />
</GuidSymbol>
<GuidSymbol value="{0C0C3FC7-F094-41A2-AE45-E63428268F53}" name="GuidMenuSet">
<IDSymbol name="TestMainMenu" value="0x1020" />
<IDSymbol name="TestMainMenuGroup" value="0x1021" />
</GuidSymbol>
2: Have the menu as the top most element. So menu <- group <- command
<Groups>
<Group guid="GuidMenuSet" id="TestMainMenuGroup" priority="0x0100">
<Parent guid="GuidMenuSet" id="TestMainMenu" />
</Group>
</Groups>
....
<Menus>
<Menu guid="GuidMenuSet" id="TestMainMenu" priority="0x0700" type="Menu">
<Parent guid="guidSHLMainMenu" id="IDG_VS_MM_TOOLSADDINS" />
<Strings>
<ButtonText>Test Menu</ButtonText>
<CommandName>Test Menu</CommandName>
</Strings>
</Menu>
</Menus>
<Groups>
<Group guid="GuidMenuSet" id="TestMainMenuGroup" priority="0x0100">
<Parent guid="GuidMenuSet" id="TestMainMenu" />
</Group>
</Groups>
....
<Menus>
<Menu guid="GuidMenuSet" id="TestMainMenu" priority="0x0700" type="Menu">
<Parent guid="guidSHLMainMenu" id="IDG_VS_MM_TOOLSADDINS" />
<Strings>
<ButtonText>Test Menu</ButtonText>
<CommandName>Test Menu</CommandName>
</Strings>
</Menu>
</Menus>
No description
Want results from more Discord servers?
Add your server