我正在开发Visual Studio扩展(VSIX).
我需要在解决方案资源管理器中右键单击类/方法/字段项,在源文件项下找到自定义右键单击菜单:

在.vsct文件中,我已经通过这种方式扩展了Solution Explorer 项目/文件夹/源文件/引用右键菜单:
<CommandPlacement guid="guidNDepend_PackageCmdSet" id="grpSolutionExplorer" priority="0x100">
<Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_ITEMNODE" />
</CommandPlacement>
<CommandPlacement guid="guidNDepend_PackageCmdSet" id="grpSolutionExplorer" priority="0x100">
<Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_PROJNODE" />
</CommandPlacement>
<CommandPlacement guid="guidNDepend_PackageCmdSet" id="grpSolutionExplorer" priority="0x100">
<Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_FOLDERNODE" />
</CommandPlacement>
<CommandPlacement guid="guidNDepend_PackageCmdSet" id="grpSolutionExplorer" priority="0x100">
<Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_REFERENCE" />
</CommandPlacement>
Run Code Online (Sandbox Code Playgroud)
我尝试了所有其他没有成功的价值观:
IDM_VS_CTXT_CODEWIN
IDM_VS_CTXT_XPROJ_MULTIITEM
IDM_VS_CTXT_XPROJ_PROJITEM
IDM_VS_CTXT_NOCOMMANDS
IDM_VS_CTXT_REFERENCEROOT
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助.
(请注意,我已经有一些棘手的代码来解析右键单击的代码元素,在调用处理程序IVsSelectionEvents.OnSelectionChanged()之前调用QueryStatus())
我创建了以下vsct文件xml.
<?xml version="1.0" encoding="utf-8"?>
<CommandTable xmlns="http://schemas.microsoft.com/VisualStudio/2005-10-18/CommandTable" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<Extern href="stdidcmd.h"/>
<Extern href="vsshlids.h"/>
<Extern href="msobtnid.h"/>
<Commands package="guidMyVSXCommandsPkg">
<Menus>
<Menu guid="guidMyVSXCommandsCmdSet" id="TopLevelMenu" priority="0x100" type="Menu">
<Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_PROJNODE"/>
<Strings>
<MenuText>Work???</MenuText>
<ButtonText>FigureMain</ButtonText>
<CommandName>TryMainMenu</CommandName>
</Strings>
</Menu>
</Menus>
<Groups>
<Group guid="guidMyVSXCommandsCmdSet" id="TopLevelMenuGroup" priority="0x0600">
<Parent guid="guidMyVSXCommandsCmdSet" id="TopLevelMenu"/>
</Group>
</Groups>
<Buttons>
<Button guid="guidMyVSXCommandsCmdSet" id="cmdidMyCommand" priority="0x0100" type="Button">
<Parent guid="guidMyVSXCommandsCmdSet" id="TopLevelMenuGroup" />
<Icon guid="guidImages" id="bmpPic1" />
<Strings>
<CommandName>cmdidMyCommand</CommandName>
<ButtonText>DO SOMETHING REAL COOL!!!!!!!!</ButtonText>
</Strings>
</Button>
</Buttons>
<Bitmaps>
<Bitmap guid="guidImages" href="Resources\Images_32bit.bmp" usedList="bmpPic1, bmpPic2, bmpPicSearch, bmpPicX, bmpPicArrows"/>
</Bitmaps>
</Commands>
<Symbols>
<!-- This is the …Run Code Online (Sandbox Code Playgroud)