VSIX Project Context Menu

妖精的绣舞 提交于 2019-12-19 09:26:34

问题


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?


回答1:


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.



回答2:


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.



来源:https://stackoverflow.com/questions/51967027/vsix-project-context-menu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!