如何在网站项目中添加上下文菜单条目? [英] How to add context menu entries in website projects?

查看:43
本文介绍了如何在网站项目中添加上下文菜单条目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法为网站项目项添加上下文菜单条目.

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

如何重现问题:

  1. 创建一个 VS 包项目
  2. 转到 vsct 文件并将 groups 部分替换为:

<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>

  • 调试包并查看:这将为简单 C# 项目中的解决方案、项目和项目项添加一个条目.但是当我创建一个 ASP.NET 网站项目(文件->新建->网站)时,除了解决方案项外,我不会得到这些条目.
  • 我确信这一定是可能的,因为 NuGet 有一个网站项目条目.不幸的是,我无法从 NuGet 源代码中提取那段代码.

    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.

    推荐答案

    过了一会儿我找到了一个解决方案:(无意中查看了 StyleCop 源代码 :P)

    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>
    

    MSDN 上没有记录这些内容.

    These are not documented on MSDN.

    无论如何,我很好奇 NuGet 是如何做到的,因为它们在 vsct 文件中没有任何内容,只有上下文菜单中的一个条目.

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

    这篇关于如何在网站项目中添加上下文菜单条目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆