Visual Studio VSIX扩展未显示在“工具”菜单中

9nvpjoqh  于 2022-12-14  发布在  其他
关注(0)|答案(5)|浏览(520)

我从2013年开始在Visual Studio中使用一个我非常喜欢的extension。这个扩展不是由它的创建者维护的,但是他在GitHub上发布了源代码。随着Visual Studio的每一个新版本,我都会尽我所能更新这个扩展,这样它仍然可以工作(我对扩展没有其他经验)。
不幸的是,在Visual Studio 2019中,微软弃用了这个扩展严重依赖的一个库(工作项跟踪)。我一直在尝试遵循他们的migration guide,但它只有几个代码示例我可以使用(主要涉及查询)。大多数需要转换的代码都超出了我的理解范围(例如:工作项存储或工作项集合)。
我已经能够成功地构建/编译项目,但由于上述原因,它有许多关于过时项的警告(“QueryItem”已过时。有关更多信息,请参阅http://aka.ms/witclientom处的文档)。但是,没有构建错误,我可以安装扩展。
安装后,可以看到扩展(和卸载)通过扩展-管理扩展页面,关于扩展的信息可以在帮助-关于屏幕中看到。但是,扩展应该在工具菜单中添加两个项目-而大多数情况下,它没有。我已经设法让这些项目显示了几次,但在尝试访问它们时会发生异常(通过VisualStudio的实验示例或常规示例)。当我停止调试以修复错误,然后卸载、构建并重新安装扩展时,工具菜单项再次丢失。我不知道如何恢复它们,我也不知道如何找出它们丢失的原因-可能是由于错误,但是调试/实验示例在这里没有帮助,因为它没有中断或显示任何错误。
是否有其他方法可以查看“工具”菜单项未显示的原因?
更新:下面是我的扩展的.vsct文件的内容。我检查了一下,似乎每一项都有自己唯一的ID。

<?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 we the 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="guidTeamPilgrimPkg">
    <!-- 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. -->

    <!-- 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="guidTeamPilgrimCmdSet" id="TeamPilgrimMenuGroup" priority="0x0600">
        <Parent guid="guidSHLMainMenu" id="IDM_VS_MENU_TOOLS"/>
      </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="guidTeamPilgrimCmdSet" id="toolTeamPilgrimExplorer" priority="0x0100" type="Button">
        <Parent guid="guidSHLMainMenu" id="IDG_VS_WNDO_OTRWNDWS1"/>
        <Icon guid="guidImages" id="bmpPic1" />
        <Strings>
          <ButtonText>Team Pilgrim Explorer</ButtonText>
        </Strings>
      </Button>

      <Button guid="guidTeamPilgrimCmdSet" id="toolTeamPilgrimPendingChanges" priority="0x0100" type="Button">
        <Parent guid="guidSHLMainMenu" id="IDG_VS_WNDO_OTRWNDWS1"/>
        <Icon guid="guidImages" id="bmpPendingChanges" />
        <Strings>
          <ButtonText>Team Pilgrim Pending Changes</ButtonText>
        </Strings>
      </Button>

      <Button guid="guidTeamPilgrimCmdSet" id="cmdTeamPilgrimExplorer" priority="0x0100" type="Button">
        <Parent guid="guidTeamPilgrimCmdSet" id="TeamPilgrimMenuGroup" />
        <Icon guid="guidImages" id="bmpPic1" />
        <Strings>
          <ButtonText>Team Pilgrim Explorer</ButtonText>
        </Strings>
      </Button>

      <Button guid="guidTeamPilgrimCmdSet" id="cmdTeamPilgrimPendingChanges" priority="0x0100" type="Button">
        <Parent guid="guidTeamPilgrimCmdSet" id="TeamPilgrimMenuGroup" />
        <Icon guid="guidImages" id="bmpPendingChanges" />
        <Strings>
          <ButtonText>Team Pilgrim Pending Changes</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="guidImages" href="Resources\Images.png" usedList="bmpPic1, bmpPendingChanges"/>

    </Bitmaps>
  </Commands>

  <Symbols>
    <!-- This is the package guid. -->
    <GuidSymbol name="guidTeamPilgrimPkg" value="{f56b8666-3ef2-46e5-ac26-8aa0efe1f484}" />

    <!-- This is the guid used to group the menu commands together -->
    <GuidSymbol name="guidTeamPilgrimCmdSet" value="{064ac9aa-5aa9-498a-a5d9-2077be8d9ad6}">

      <IDSymbol name="TeamPilgrimMenuGroup" value="0x1020" />
      <IDSymbol name="cmdTeamPilgrimExplorer" value="0x0100" />
      <IDSymbol name="toolTeamPilgrimExplorer" value="0x0101" />
      <IDSymbol name="cmdTeamPilgrimPendingChanges" value="0x0102" />
      <IDSymbol name="toolTeamPilgrimPendingChanges" value="0x0103" />
    </GuidSymbol>  

    <GuidSymbol name="guidImages" value="{91572e9b-72ad-453b-93df-dfc995721a79}" >
      <IDSymbol name="bmpPic1" value="1" />
      <IDSymbol name="bmpPendingChanges" value="2" />
      <IDSymbol name="bmpPicSearch" value="3" />
      <IDSymbol name="bmpPicX" value="4" />
      <IDSymbol name="bmpPicArrows" value="5" />
      <IDSymbol name="bmpPicStrikethrough" value="6" />
    </GuidSymbol>
  </Symbols>

</CommandTable>
bgibtngc

bgibtngc1#

如果您像我一样来到这里,试图找出为什么您的工作扩展突然(对您来说)丢失了所有工具栏和菜单-那么请检查您的.vsct文件是否真的由VSCT编译器处理-它应该是一个VSCTCompile项-类似于以下内容

<VSCTCompile Include="MainPackage.vsct">
  <AutoGen>True</AutoGen>
  <DesignTime>True</DesignTime>
  <DependentUpon>MainPackage.tt</DependentUpon>
  <ResourceName>Menus.ctmenu</ResourceName>
  <SubType>Designer</SubType>
</VSCTCompile>  </ItemGroup>

而不是像我这样

<Content Include="MainPackage.vsct">
  <AutoGen>True</AutoGen>
  <DesignTime>True</DesignTime>
  <DependentUpon>MainPackage.tt</DependentUpon>
</Content>
apeeds0o

apeeds0o2#

然而,扩展应该在工具菜单中添加两个项目--而大多数时候,它并没有。
1.从VS 2019开始,它将阻止任何扩展同步自动加载。如果你收到任何警告,你可能需要升级扩展以支持异步后台加载。更多细节请参考this blog
2.也许您的xx.vsct文件有问题,如果其中的结构无效,构建不会失败并抛出错误,但您可能看不到显示的Item...
Microsoft已弃用此扩展严重依赖的一个库(工作项跟踪)
这个API更像是TFS API,而不是VS SDK API,我猜你找不到这两个项目的原因是关于tip 1或tip 2,而你在尝试访问它们时得到异常的原因是关于那些API被弃用,所以我猜你可能需要使用新的REST APIS

k2arahey

k2arahey3#

我也遇到过类似的问题,一个旧的扩展也使用了过时的API。在Visual Studio 2019的第一个版本中,它工作正常,但在VS更新后,其中一个窗口停止正常工作,变成了“空白窗口”。我花了几个月的时间在谷歌上搜索解决这个问题的方法,我可以通过禁用工具-〉选项-〉环境-〉常规-〉“优化具有不同像素密度的屏幕的渲染”中的选项来修复它

kgsdhlau

kgsdhlau4#

以下步骤似乎可以在VS的实验示例(使用2022)上恢复“工具”菜单状态:
1.使用“注册表编辑器”删除或重命名HKEY_CURRENT_USER\SOFTWARE\Microsoft\VisualStudio\17.0_7d3fd73aExp(或适用于您的VS版本的等效项)。
1.通过运行以下命令重置实验示例:'重置Visual Studio 2022实验示例'
1.重新部署VSIX包(或在选中“Deploy VSIX content to experimental instance for debugging”(将VSIX内容部署到实验示例以进行调试)选项的情况下通过VS重新构建)
希望这能有所帮助!

hivapdat

hivapdat5#

修复“丢失图标”的快速方法:
1.打开VS开发人员提示
1.关闭所有VS示例
1.运行devenv /updateConfiguration

相关问题