Search code examples
visual-studio-2010vspackagevs-extensibility

What is the "Organize Usings" menu ID in Visual Studio 2010?


I'm creating a Visual Studio 2010 extension using a Package template, not an Add-in.

I want to add a menu item to the "Organize Usings" menu group that appears when you right-click in a .cs file. To do this, I need the guid and the id of that menu group.

<Button guid="myCmdSet" id="myButton" priority="0x0100" type="Button">
    <Parent guid="guidSHLMainMenu (I think?)" id="???" />
    <Icon guid="guidImages" id="bmpPic1" />
    <Strings>
      <CommandName>myCommand</CommandName>
      <ButtonText>Do Stuff</ButtonText>
    </Strings>
  </Button>

I have looked here and here and here. Basically all around MSDN. Are these published, and does anyone know what they are?

EDIT: I found the related menu via this method, but I still don't have a way to find the menu group GUID/ID, which is what I really want.


Solution

  • OMG, I've spend 3 hours on this :D Here's the solution:

    <?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">
      <Extern href="stdidcmd.h"/>
      <Extern href="vsshlids.h"/>
      <Extern href="msobtnid.h"/>
      <Commands package="guidVSPackage1Pkg">
        <Buttons>      
          <Button guid="guidCSharpGrpId" id="mySuperCommand" priority="0x0200" type="Button">
            <Parent guid="guidCSharpGrpId" id="IDG_CSHARP_CTX_ORGANIZE" />
            <Icon guid="guidImages" id="bmpPic1" />
            <Strings>
              <CommandName>mySuperCommand</CommandName>
              <ButtonText>My super command</ButtonText>
            </Strings>
          </Button>
        </Buttons>
        <Bitmaps>
          <Bitmap guid="guidImages" href="Resources\Images_32bit.bmp" usedList="bmpPic1, bmpPic2, bmpPicSearch, bmpPicX, bmpPicArrows"/>
        </Bitmaps>
      </Commands>
      <Symbols>
        <!-- This is the package guid. -->
        <GuidSymbol name="guidVSPackage1Pkg" value="{F066e284-dcab-11d2-b551-00c04f68d4db}" />
        <GuidSymbol name="guidCSharpGrpId" value="{5d7e7f65-a63f-46ee-84f1-990b2cab23f9}">
          <IDSymbol name="IDG_CSHARP_CTX_ORGANIZE" value="0x3618" />
          <IDSymbol name="mySuperCommand" value="0x0100" />
        </GuidSymbol>
        <GuidSymbol name="guidImages" value="{cff24f4c-767f-48ee-aff4-6bdf8218cba0}" >
          <IDSymbol name="bmpPic1" value="1" />
          <IDSymbol name="bmpPic2" value="2" />
          <IDSymbol name="bmpPicSearch" value="3" />
          <IDSymbol name="bmpPicX" value="4" />
          <IDSymbol name="bmpPicArrows" value="5" />
        </GuidSymbol>
      </Symbols>
    </CommandTable>
    

    You must place guidCSharpGrpId and IDG_CSHARP_CTX_ORGANIZE because they're not available in "standard" set of id's. By "standard" I'mean those placed in VisualStudioIntegration\Common\Inc directory within *.h files. They're hidden in cslangsvcui.dll library.

    To get these ID's I've used VS Command Table PowerToy. You can download it from here: http://archive.msdn.microsoft.com/VSCTPowerToy

    Check this also as this thread: http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/697245ac-1596-4d6a-b55c-f5b01b69a583

    In case that this solution won't work for you because some guids, etc. I've put zipped project on my SkyDrive: https://skydrive.live.com/#cid=6A19F3A9B7B8E017&id=6A19F3A9B7B8E017!16486

    Hope this helps :)