Keyboard 在为VS2015实现VSPackage(VSIX)时,如何获得选项键盘中列出的新命令?

Keyboard 在为VS2015实现VSPackage(VSIX)时,如何获得选项键盘中列出的新命令?,keyboard,visual-studio-2015,vsix,vspackage,Keyboard,Visual Studio 2015,Vsix,Vspackage,我刚刚创建了我的第一个VSPackage(因为VS2015不支持加载项) 虽然我已经设法在我的VSPackage中分配了键盘快捷键(使用键绑定),但我发现命令本身似乎没有列在VisualStudio的“选项键盘”选项卡中 我注意到,我安装的其他扩展包括用于在键盘选项中分配的命令 我必须怎么做才能把我的也包括进去 以下是我的VSCT文件的全部内容-如果有更好的附加方式,我深表歉意,但我找不到: <?xml version="1.0" encoding="utf-8"?> <Com

我刚刚创建了我的第一个VSPackage(因为VS2015不支持加载项)

虽然我已经设法在我的VSPackage中分配了键盘快捷键(使用键绑定),但我发现命令本身似乎没有列在VisualStudio的“选项键盘”选项卡中

我注意到,我安装的其他扩展包括用于在键盘选项中分配的命令

我必须怎么做才能把我的也包括进去

以下是我的VSCT文件的全部内容-如果有更好的附加方式,我深表歉意,但我找不到:

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

  <!--  This is the file that defines the actual layout and type of the commands.
        It is divided in different sections (e.g. command definition, command
        placement, ...), with each defining a specific set of properties.
        See the comment before each section for more details about how to
        use it. -->

  <!--  The VSCT compiler (the tool that translates this file into the binary
        format that VisualStudio will consume) has the ability to run a preprocessor
        on the vsct file; this preprocessor is (usually) the C++ preprocessor, so
        it is possible to define includes and macros with the same syntax used
        in C++ files. Using this ability of the compiler here, we include some files
        defining some of the constants that we will use inside the file. -->

  <!--This is the file that defines the IDs for all the commands exposed by VisualStudio. -->
  <Extern href="stdidcmd.h" />

  <!--This header contains the command ids for the menus provided by the shell. -->
  <Extern href="vsshlids.h" />

  <!--The Commands section is where commands, menus, and menu groups are defined.
      This section uses a Guid to identify the package that provides the command defined inside it. -->
  <Commands package="guidDanBarPackage">
    <!-- Inside this section we have different sub-sections: one for the menus, another
    for the menu groups, one for the buttons (the actual commands), one for the combos
    and the last one for the bitmaps used. Each element is identified by a command id that
    is a unique pair of guid and numeric identifier; the guid part of the identifier is usually
    called "command set" and is used to group different command inside a logically related
    group; your package should define its own command set in order to avoid collisions
    with command ids defined by other packages. -->

    <Menus>
        <Menu guid="guidDanBarPackageCmdSet" id="MyToolbar" type="Toolbar">
            <CommandFlag>DefaultDocked</CommandFlag>
            <Strings>
                <ButtonText>Dan Bar</ButtonText>
                <CommandName>Dan Bar</CommandName>
            </Strings>
        </Menu>
    </Menus>

    <Menus>
        <Menu guid="guidDanBarPackageCmdSet" id="BriefToolbar" type="Toolbar">
            <CommandFlag>DefaultDocked</CommandFlag>
            <Strings>
                <ButtonText>Dan Brief Bar</ButtonText>
                <CommandName>Dan Brief Bar</CommandName>
            </Strings>
        </Menu>
    </Menus>

    <!-- In this section you can define new menu groups. A menu group is a container for
         other menus or buttons (commands); from a visual point of view you can see the
         group as the part of a menu contained between two lines. The parent of a group
         must be a menu. -->
    <Groups>
      <Group guid="guidDanBarPackageCmdSet" id="MyToolbarGroup" priority="0x0000">
        <Parent guid="guidDanBarPackageCmdSet" id="MyToolbar" />
      </Group>

      <Group guid="guidDanBarPackageCmdSet" id="BriefToolbarGroup" priority="0x0000">
        <Parent guid="guidDanBarPackageCmdSet" id="BriefToolbar" />
      </Group>
    </Groups>

    <!--Buttons section. -->
    <!--This section defines the elements the user can interact with, like a menu command or a button
        or combo box in a toolbar. -->
    <Buttons>
      <!--To define a menu group you have to specify its ID, the parent menu and its display priority.
          The command is visible and enabled by default. If you need to change the visibility, status, etc, you can use
          the CommandFlag node.
          You can add more than one CommandFlag node e.g.:
              <CommandFlag>DefaultInvisible</CommandFlag>
              <CommandFlag>DynamicVisibility</CommandFlag>
          If you do not want an image next to your command, remove the Icon node /> -->
      <Button guid="guidDanBarPackageCmdSet" id="cmdidConcurrentBuilds" priority="0x0100" type="Button">
        <Parent guid="guidDanBarPackageCmdSet" id="MyToolbarGroup" />
        <Icon guid="guidDanBarImages" id="bmpPic1" />
        <Strings>
          <ButtonText>Set Concurrent Builds</ButtonText>
        </Strings>
      </Button>
      <Button guid="guidDanBarPackageCmdSet" id="cmdidTrackInSolutionExplorer" priority="0x0100" type="Button">
        <Parent guid="guidDanBarPackageCmdSet" id="MyToolbarGroup" />
        <Icon guid="guidDanBarImages" id="bmpPic2" />
        <Strings>
          <ButtonText>Track In Solution Explorer</ButtonText>
        </Strings>
      </Button>
      <Button guid="guidDanBarPackageCmdSet" id="cmdidBuildStartupProject" priority="0x0100" type="Button">
        <Parent guid="guidDanBarPackageCmdSet" id="MyToolbarGroup" />
        <Icon guid="guidDanBarImages" id="bmpPic3" />
        <Strings>
          <ButtonText>Build Startup Project</ButtonText>
        </Strings>
      </Button>
      <Button guid="guidDanBarPackageCmdSet" id="cmdidCommentOutParam" priority="0x0100" type="Button">
        <Parent guid="guidDanBarPackageCmdSet" id="MyToolbarGroup" />
        <Icon guid="guidDanBarImages" id="bmpPic4" />
        <Strings>
          <ButtonText>Comment Out Parameter</ButtonText>
        </Strings>
      </Button>
      <Button guid="guidDanBarPackageCmdSet" id="cmdidInsertRegion" priority="0x0100" type="Button">
        <Parent guid="guidDanBarPackageCmdSet" id="MyToolbarGroup" />
        <Icon guid="guidDanBarImages" id="bmpPic5" />
        <Strings>
          <ButtonText>Insert Region</ButtonText>
        </Strings>
      </Button>
      <Button guid="guidDanBarPackageCmdSet" id="cmdidXMLCommentFull" priority="0x0100" type="Button">
        <Parent guid="guidDanBarPackageCmdSet" id="MyToolbarGroup" />
        <Icon guid="guidDanBarImages" id="bmpPic6" />
        <Strings>
          <ButtonText>Full XML Comment</ButtonText>
        </Strings>
      </Button>
      <Button guid="guidDanBarPackageCmdSet" id="cmdidXMLCommentSmall" priority="0x0100" type="Button">
        <Parent guid="guidDanBarPackageCmdSet" id="MyToolbarGroup" />
        <Icon guid="guidDanBarImages" id="bmpPic7" />
        <Strings>
          <ButtonText>Small XML Comment</ButtonText>
        </Strings>
      </Button>
      <Button guid="guidDanBarPackageCmdSet" id="cmdidXMLCommentTiny" priority="0x0100" type="Button">
        <Parent guid="guidDanBarPackageCmdSet" id="MyToolbarGroup" />
        <Icon guid="guidDanBarImages" id="bmpPic8" />
        <Strings>
          <ButtonText>Tiny XML Comment</ButtonText>
        </Strings>
      </Button>
      <Button guid="guidDanBarPackageCmdSet" id="cmdidXMLCommentMember" priority="0x0100" type="Button">
        <Parent guid="guidDanBarPackageCmdSet" id="MyToolbarGroup" />
        <Icon guid="guidDanBarImages" id="bmpPic9" />
        <Strings>
          <ButtonText>Member XML Comment</ButtonText>
        </Strings>
      </Button>
      <Button guid="guidVSStd97" id="cmdidMoreWindows" priority="0x0100" type="Button">
        <Parent guid="guidDanBarPackageCmdSet" id="MyToolbarGroup" />
        <Icon guid="guidDanBarImages" id="bmpPic10" />
        <Strings>
          <ButtonText>Win...</ButtonText>
        </Strings>
      </Button>

      <!--BRIEF buttons-->
      <Button guid="guidDanBarPackageCmdSet" id="cmdidBriefAltD" priority="0x0100" type="Button">
        <Parent guid="guidDanBarPackageCmdSet" id="BriefToolbarGroup" />
        <Icon guid="guidBriefBarImages" id="bmpPic1" />
        <Strings>
          <ButtonText>Brief Alt D - Line Delete</ButtonText>
        </Strings>
      </Button>
      <Button guid="guidDanBarPackageCmdSet" id="cmdidBriefAltMinus" priority="0x0100" type="Button">
        <Parent guid="guidDanBarPackageCmdSet" id="BriefToolbarGroup" />
        <Icon guid="guidBriefBarImages" id="bmpPic3" />
        <Strings>
          <ButtonText>Brief Num-Minus - Line Cut</ButtonText>
        </Strings>
      </Button>
      <Button guid="guidDanBarPackageCmdSet" id="cmdidBriefAltPlus" priority="0x0100" type="Button">
      <Parent guid="guidDanBarPackageCmdSet" id="BriefToolbarGroup" />
      <Icon guid="guidBriefBarImages" id="bmpPic4" />
      <Strings>
          <ButtonText>Brief Num-Plus - Line Copy</ButtonText>
      </Strings>
      </Button>
      <Button guid="guidDanBarPackageCmdSet" id="cmdidBriefAltC" priority="0x0100" type="Button">
        <Parent guid="guidDanBarPackageCmdSet" id="BriefToolbarGroup" />
        <Icon guid="guidBriefBarImages" id="bmpPic2" />
        <Strings>
          <ButtonText>Brief Alt C - Block Select</ButtonText>
        </Strings>
      </Button>
      <Button guid="guidDanBarPackageCmdSet" id="cmdidBriefLinePaste" priority="0x0100" type="Button">
      <Parent guid="guidDanBarPackageCmdSet" id="BriefToolbarGroup" />
      <Icon guid="guidBriefBarImages" id="bmpPic5" />
      <Strings>
          <ButtonText>Brief Insert - Line Paste</ButtonText>
      </Strings>
      </Button>

    </Buttons>

    <!--The bitmaps section is used to define the bitmaps that are used for the commands.-->
    <Bitmaps>
      <!--  The bitmap id is defined in a way that is a little bit different from the others:
            the declaration starts with a guid for the bitmap strip, then there is the resource id of the
            bitmap strip containing the bitmaps and then there are the numeric ids of the elements used
            inside a button definition. An important aspect of this declaration is that the element id
            must be the actual index (1-based) of the bitmap inside the bitmap strip. -->
      <Bitmap guid="guidDanBarImages" href="Resources\DanBar.png" usedList="bmpPic1, bmpPic2, bmpPic3, bmpPic4, bmpPic5, bmpPic6, bmpPic7, bmpPic8, bmpPic9, bmpPic10" />
      <Bitmap guid="guidBriefBarImages" href="Resources\BriefBar.png" usedList="bmpPic1, bmpPic2, bmpPic3, bmpPic4, bmpPic5, bmpPic6" />
    </Bitmaps>
  </Commands>

  <KeyBindings>
      <KeyBinding guid="guidDanBarPackageCmdSet" id="cmdidXMLCommentSmall" editor="guidVSStd97" key1="q" mod1="Alt" />
      <KeyBinding guid="guidDanBarPackageCmdSet" id="cmdidBriefAltD" editor="guidVSStd97" key1="d" mod1="Alt" />
      <KeyBinding guid="guidDanBarPackageCmdSet" id="cmdidBriefAltMinus" editor="guidVSStd97" key1="VK_SUBTRACT" />
      <KeyBinding guid="guidDanBarPackageCmdSet" id="cmdidBriefAltPlus" editor="guidVSStd97" key1="VK_ADD" />
      <KeyBinding guid="guidDanBarPackageCmdSet" id="cmdidBriefAltC" editor="guidVSStd97" key1="c" mod1="Alt" />
      <KeyBinding guid="guidDanBarPackageCmdSet" id="cmdidBriefLinePaste" editor="guidVSStd97" key1="VK_INSERT" />
  </KeyBindings>

  <Symbols>
    <!-- This is the package guid. -->
    <GuidSymbol name="guidDanBarPackage" value="{69fa005b-6bae-4a69-84e6-ed7cf75cc180}" />

    <!-- This is the guid used to group the menu commands together -->
    <GuidSymbol name="guidDanBarPackageCmdSet" value="{a2ce5715-189e-4bfc-bc37-4d1b6e0c1122}">
      <IDSymbol name="MyToolbar" value="0x1000" />
      <IDSymbol name="MyToolbarGroup" value="0x1050" />
      <IDSymbol name="BriefToolbar" value="0x1100" />
      <IDSymbol name="BriefToolbarGroup" value="0x1150" />
      <IDSymbol name="cmdidConcurrentBuilds" value="256" />
      <IDSymbol name="cmdidTrackInSolutionExplorer" value="257" />
      <IDSymbol name="cmdidBuildStartupProject" value="258" />
      <IDSymbol name="cmdidCommentOutParam" value="259" />
      <IDSymbol name="cmdidXMLCommentFull" value="260" />
      <IDSymbol name="cmdidXMLCommentSmall" value="261" />
      <IDSymbol name="cmdidXMLCommentTiny" value="262" />
      <IDSymbol name="cmdidXMLCommentMember" value="263" />
      <IDSymbol name="cmdidInsertRegion" value="264" />
      <IDSymbol name="cmdidBriefAltD" value="270" />
      <IDSymbol name="cmdidBriefAltMinus" value="271" />
      <IDSymbol name="cmdidBriefAltPlus" value="272" />
      <IDSymbol name="cmdidBriefAltC" value="273" />
      <IDSymbol name="cmdidBriefLinePaste" value="274" />
    </GuidSymbol>

    <GuidSymbol name="guidDanBarImages" value="{ffb25733-9517-4411-bae2-4deda791fd6c}">
      <IDSymbol name="bmpPic1" value="1" />
      <IDSymbol name="bmpPic2" value="2" />
      <IDSymbol name="bmpPic3" value="3" />
      <IDSymbol name="bmpPic4" value="4" />
      <IDSymbol name="bmpPic5" value="5" />
      <IDSymbol name="bmpPic6" value="6" />
      <IDSymbol name="bmpPic7" value="7" />
      <IDSymbol name="bmpPic8" value="8" />
      <IDSymbol name="bmpPic9" value="9" />
      <IDSymbol name="bmpPic10" value="10" />
    </GuidSymbol>

    <GuidSymbol name="guidBriefBarImages" value="{f1a36fcd-2c27-4151-ae23-42fff88c212c}">
      <IDSymbol name="bmpPic1" value="1" />
      <IDSymbol name="bmpPic2" value="2" />
      <IDSymbol name="bmpPic3" value="3" />
      <IDSymbol name="bmpPic4" value="4" />
      <IDSymbol name="bmpPic5" value="5" />
      <IDSymbol name="bmpPic6" value="6" />
    </GuidSymbol>

  </Symbols>
</CommandTable>

默认停靠
丹巴
丹巴
默认停靠
丹酒吧
丹酒吧
设置并发生成
在解决方案资源管理器中跟踪
构建启动项目
注释掉参数
插入区域
完整XML注释
小XML注释
微小的XML注释
成员XML注释
赢
简短Alt D-行删除
简短的数字减线切割
简短数字加行复制
简短Alt C-块选择
简短插入-行粘贴

您应该在Visual Studio命令表(.vsct)文件中定义命令,并在代码中为它们创建事件处理程序。看

VS 2015包括自定义命令模板,您可以将其添加到项目中以快速启动:

您应该在Visual Studio命令表(.vsct)文件中定义命令,并在代码中为它们创建事件处理程序。看

VS 2015包括自定义命令模板,您可以将其添加到项目中以快速启动:

通常,命令属于菜单,并包含在此菜单的选项键盘中。由于您的命令只属于工具栏,因此情况并非如此

您可以将LocCanonicalName标记添加到.vsct按钮定义中,以将命令包含到选项键盘中,如下所示:

 <Strings>
   <LocCanonicalName>DanBar.TrackInSolutionExplorer</LocCanonicalName>
   <ButtonText>Track In Solution Explorer</ButtonText>
 </Strings>

丹巴轨道探索公司
在解决方案资源管理器中跟踪

通常,命令属于菜单,并包含在此菜单的选项键盘中。由于您的命令只属于工具栏,因此情况并非如此

您可以将LocCanonicalName标记添加到.vsct按钮定义中,以将命令包含到选项键盘中,如下所示:

 <Strings>
   <LocCanonicalName>DanBar.TrackInSolutionExplorer</LocCanonicalName>
   <ButtonText>Track In Solution Explorer</ButtonText>
 </Strings>

丹巴轨道探索公司
在解决方案资源管理器中跟踪

谢谢@Sergey。是的,这就是我所做的(除了使用VB.Net,因为我的外接程序是作为一组宏开始的)。我添加了2个工具栏,其中包含总共10个自定义命令(它们都可以工作),但这些“自定义命令”都没有在“选项键盘”中列出。这就是让我困惑的地方。你能发布你的项目或者至少是.vsct文件吗?谢谢@Sergey。我现在已将完整的VSCT包含在问题中。您可能会注意到我尝试将标准的“Windows…”按钮重命名为“Win…”并将图标与其关联以包含在工具栏中时失败。这没用。谢谢@Sergey。是的,这就是我所做的(除了使用VB.Net,因为我的外接程序是作为一组宏开始的)。我添加了2个工具栏,其中包含总共10个自定义命令(它们都可以工作),但这些“自定义命令”都没有在“选项键盘”中列出。这就是让我困惑的地方。你能发布你的项目或者至少是.vsct文件吗?谢谢@Sergey。我现在已将完整的VSCT包含在问题中。您可能会注意到我尝试将标准的“Windows…”按钮重命名为“Win…”并将图标与其关联以包含在工具栏中时失败。这没用,真有趣。非常感谢@Sergey-我会试试的。这很有趣。非常感谢@Sergey-我会试试的。