VSIX Project Context Menu
Asked Answered
I

2

6

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?

Interrupted answered 22/8, 2018 at 12:33 Comment(0)
C
7

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.
Churchman answered 23/8, 2018 at 7:0 Comment(3)
Info you provided is very useful. How would you achieve this behaviour, but only on web projects nodes in the Solution Explorer?Interrupted
It's a trial and error approach. Try the element containing "web" in the VsctBuiltInCache.cs that I linkedChurchman
I'll try soon and let you knowInterrupted
P
0

I think and hope this might help, though it is a general answer and not a specific one. Learn by example.

I also hope the WiX authors won't mind, but I believe the source for their Visual Studio integration component "WiX Votive" is here: https://github.com/wixtoolset/VisualStudioExtension.

There is also this: https://github.com/wixtoolset/VisualStudio.wixext. I am not sure what this is to be honest. I should, but I don't. Mr.Arnson - I summon theee (WiX developer - The Matrix's got you).


WiX Votive - VS Integration is part of the overall WiX Toolset - which is a Windows Installer deployment solution capable of compiling MSI files from XML markup. MSI files are the binary deployment files used by Windows Installer for deployment on Windows.

If of interest you 1) download and install WiX itself (currently 3.11.1), and 2) download and install the correct Visual Studio integration (the marketplace links underneath the main download) making sure you get the correct version for your Visual Studio version - of course. Both downloads from the same link (or use the Visual Studio marketplace).

Here are some further details: WiX quick-overview.

Planetesimal answered 22/8, 2018 at 19:48 Comment(1)
VisualStudioExtension is where Votive lives. VisualStudio.wixext is where WixToolset.VisualStudio.wixext.dll lives.Rozier

© 2022 - 2024 — McMap. All rights reserved.