How to add context menu entries in website projects?

烂漫一生 提交于 2019-12-18 07:02:35

问题


I'm not able to add context menu entries for website project items.

How to reproduce the problem:

  1. Create a VS Package project
  2. Go to the vsct file and replace the groups section with:

    <Group guid="guidVSPackage1CmdSet" id="MyMenuGroup" priority="0x0600">
       <Parent guid="guidSHLMainMenu" id="IDM_VS_MENU_TOOLS"/>
    </Group>
    
    <Group guid="guidVSPackage1CmdSet" id="MyMenuGroup" priority="0x0600">
       <Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_PROJNODE"/>
    </Group>
    
    <Group guid="guidVSPackage1CmdSet" id="MyMenuGroup" priority="0x0600">
       <Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_ITEMNODE"/>
    </Group>
    
    <Group guid="guidVSPackage1CmdSet" id="MyMenuGroup" priority="0x0600">
       <Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_FOLDERNODE"/>
    </Group>
    
    <Group guid="guidVSPackage1CmdSet" id="MyMenuGroup" priority="0x0600">
       <Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_SOLNNODE"/>
    </Group>
    
  3. Debug the package and see: This will add an entry for the solution, project and project items in a simple C# project. But when I create a ASP.NET website project (File->New->WebSite) I won't get these entries except for the solution item.

I'm sure this must be possible due to the fact, that NuGet has an entry for the website project item. unfortunately, I was not able to extract that piece of code from the NuGet source code.


回答1:


After a while I found a solution: (I accidentally looked into the StyleCop source code :P)

<Group guid="guidVSPackage1CmdSet" id="MyMenuGroup" priority="0x0050">
  <Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_WEBFOLDER"/>
</Group>

<Group guid="guidVSPackage1CmdSet" id="MyMenuGroup" priority="0x0050">
  <Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_WEBITEMNODE"/>
</Group>

<Group guid="guidVSPackage1CmdSet" id="MyMenuGroup" priority="0x0050">
  <Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_WEBPROJECT"/>
</Group>

These are not documented on MSDN.

Anyway, I'm curious how NuGet does it, because they have nothing in the vsct file, but an entry in the context menu.



来源:https://stackoverflow.com/questions/12088469/how-to-add-context-menu-entries-in-website-projects

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