Search code examples
c#vsixvspackage

How to merge two top level menu with same name from different extension in visual studio using vspackage


I create top level menu with name "CustomMenu" from extension project and also create another top level menu with same name from another extension project.After I install both extension menu shows multiple times .

How to I merge top level menu from multiple extension(VSIX) in the visual studio. enter image description here


Solution

  • "Merging" as such is not possible. While the caption of both top level menus are the same, they are different items, each one identified by two pieces that you specify in the <menu> element of the .vsct file:

    1. A Guid for the command set of the package that you declare also in the .vsct file
    2. An Id for menu

    The Ids can be the same in two packages, but the Guids are (and should be) unique for each package.

    What you can do, if the extensions are guaranteed to be installed always in the same order, is to create the groups (which are the parents of menu entries, buttons, etc.) of the second package on the top menu created by the first package, using its Guid/Id as parent (like you would do adding new items to built-in menus provided by VS, where you use "guidSHLMainMenu" which is the guid of the command set of Visual Studio main menu).