Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

visual studio 2010 - How to add context menu entries in website projects?

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...