簡體   English   中英

Visual Studio VSIX 擴展未顯示在“工具”菜單中

[英]Visual Studio VSIX Extension not showing in Tools menu

自 2013 版以來,我一直在使用 Visual Studio 中我非常喜歡的擴展。該擴展不是由其創建者維護的,但他在 GitHub 上發布了源代碼。對於 Visual Studio 的每個新版本,我都會盡力更新擴展所以它仍然可以工作(我沒有其他擴展經驗)。

不幸的是,在 Visual Studio 2019 中,Microsoft 棄用了此擴展嚴重依賴的庫之一(工作項跟蹤)。 我一直在嘗試遵循他們的遷移指南,但它只有幾個我可以使用的代碼示例(主要涉及查詢)。 大多數需要轉換的代碼都在我的腦海中(例如:WorkItemStore 或 WorkItemCollection)。

我已經能夠讓項目成功構建/編譯,但由於上述原因,它有許多關於過時項目的警告('QueryItem' 已過時。有關更多信息,請參閱文檔http://aka.ms/witclientom ). 但是,沒有構建錯誤,我可以安裝擴展。

安裝后,可以通過擴展 - 管理擴展頁面查看(和卸載)擴展,有關擴展的信息可以在幫助 - 關於屏幕中查看。 但是,擴展應該向“工具”菜單添加兩個項目——大多數情況下,它不會。 我設法讓項目顯示了幾次,但在嘗試訪問它們時會出現異常(通過 Visual Studio 的實驗實例或常規實例)。 當我停止調試以修復錯誤,然后卸載、構建並重新安裝擴展時,工具菜單項再次丟失。 我不知道如何取回它們,也不知道如何找出它們丟失的原因 - 可能是由於錯誤,但調試/實驗實例在這里沒有幫助,因為它不會中斷或顯示任何錯誤。

有沒有其他方法可以讓我了解為什么“工具”菜單項未顯示?

更新:這是我的擴展程序的 .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>

如果你像我一樣來到這里,試圖找出為什么你的工作擴展突然(對你)丟失了所有工具欄和菜單 - 然后請檢查你的 .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>

然而,擴展應該在工具菜單中添加兩個項目——而且大多數時候,它不會。

1.自VS2019起,它將阻止任何擴展同步自動加載。 如果您收到任何警告,您可能需要升級擴展以支持異步后台加載。 更多詳細信息請參閱此博客

2.可能你的xx.vsct文件有問題,如果里面的結構無效,構建不會失敗並拋出錯誤,但你可能看不到顯示的項目...

Microsoft 棄用了此擴展嚴重依賴的庫之一(工作項跟蹤)

This API is more like TFS API , not VS SDK API , I guess the reason why you can't find the two items is about tip1 or tip2, and the reason why you get an exception when trying to access them is about those APIS are已棄用,所以我猜您可能需要使用新的REST APIS

我在使用已棄用的 API 的舊擴展時遇到了類似的問題。 在 Visual Studio 2019 的第一個版本中,它工作正常,但在 VS 更新后,其中一個 windows 停止正常工作並成為“空白窗口”。 我花了幾個月的時間在谷歌上搜索解決這個問題的方法,我可以通過禁用工具 -> 選項 -> 環境 -> 常規 -> “優化具有不同像素密度的屏幕的渲染”中的選項來修復它

以下步驟似乎可以恢復VS實驗實例上的Tools菜單state(使用2022):

  1. 使用 'Regedit' 刪除或重命名 HKEY_CURRENT_USER\SOFTWARE\Microsoft\VisualStudio\17.0_7d3fd73aExp(或您的 VS 版本的等效項)。
  2. 通過運行重置實驗實例:“重置 Visual Studio 2022 實驗實例”
  3. 重新部署您的 VSIX package(或通過 VS 重建它,同時選中“將 VSIX 內容部署到實驗實例以進行調試”選項)

希望這會有所幫助!

修復“丟失的圖標”的快速方法:

  1. 打開 VS 開發者提示
  2. 關閉所有 VS 實例
  3. 運行devenv /updateConfiguration

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM