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

1

0

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

Usanis answered 10/2, 2019 at 17:12 Comment(0)
A
0

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

Ardie answered 11/2, 2019 at 15:35 Comment(4)
I know this is an old post, but I'm trying to make the same with VS2022 and I'm getting in trouble with this approach. It seems that the second package overwrites the first one, so I lost items from the top-level menu added with the first package. Any idea? Would be better to open a new post for this?Wiretap
Hi. I hate to challenge a question instead of answering it, but I will do it: why are you the second person that has two separate VS packages that want to share the same top level custom menu? I mean: if you own the two VS packages: 1) Couldn't you merge the two VS packages into a single one, so that the issue disappears? 2) Couldn't you add the menu entries of the two packages into a built-in top level menu provided by VS, such as the "Tools" menu?Ardie
Anyway, if you really want two separate VS packages sharing the same custom top level menu you should create a new post showing the .vsct files of the two packages (try to make them minimal to reproduce the issue).Ardie
one package contains common menu items for all the versions of the product, and the second one contains specific menu items for that particular version. Since 2 major releases of the product can be installed side-by-side on the machine, every installer will contain common package+version package. In the meantime, I found this post that solved my issue: #76464377 Anyway, if you want to suggest to me a different approach for this scenario, please feel free to reply here, thanks.Wiretap

© 2022 - 2024 — McMap. All rights reserved.