Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSIX Project Context Menu

I'm trying to create a Visual Studio 2017 extension, just for fun and to learn how VS extensibility works.

My extension must be usable from the Solution Explorer tab as a context menu button, but I would like to include it at a menu level that isn't root.

My goal is to put it in the "Add" sub-menu, but at the moment I'm only able to put it at root level (when you right-click the Project item, the menu entry is shown as the last of the context menu control).

How can I move it under the "Add" node?
Can it be done from the CommandPlacement tags I have configured in my .vsct file?

like image 751
mororo Avatar asked Aug 22 '18 12:08

mororo


People also ask

What is VSIX format?

A VSIX package is a . vsix file that contains one or more Visual Studio extensions, together with the metadata Visual Studio uses to classify and install the extensions. That metadata is contained in the VSIX manifest and the [Content_Types]. xml file. A VSIX package may also contain one or more Extension.

How do I add a command in Visual Studio?

In the Solution Explorer, right-click the project node and select Add > New Item. In the Add New Item dialog, go to Visual C# > Extensibility and select Command.


1 Answers

Use as parent of your command the IDG_VS_CTXT_PROJECT_ADD_ITEMS group id. If you are using CommandPlacement it would be:

  <CommandPlacement guid="..." id="..." priority="0x0001" >
     <Parent guid="guidSHLMainMenu" id="IDG_VS_CTXT_PROJECT_ADD_ITEMS"/>
  </CommandPlacement>

Remember:

  • The parent of a group can be another group, a menu, a toolbar, a context menu, etc. either created by your extension or an existing one of VS, identified by prefix "IDM_". See GUIDs and IDs of Visual Studio menus and GUIDs and IDs of Visual Studio toolbars.
  • The parent of a command is always a group, never a menu, context menu or toolbar. The group can be new (created by your extension) or an existing group of Visual Studio, identified by prefix "IDG_". You have some built-in Visual Studio groups in the links above, but for a more exhaustive list install the ExtensionTools extension (Mads Kristensen) that provides intellisense in the .vsct file or check the source code of its VsctBuiltInCache.cs file.
like image 174
Carlos Quintero Avatar answered Nov 09 '22 02:11

Carlos Quintero