locked
My context menu item made by menu command in Visual Studio Package is not shown in cshtml files. RRS feed

  • Question

  • I made a menu command and it works fine in .cs files as you can see below.

    

    The penultimate item "Build this project" is the created item.

    But when I try it in cshtml files, this item is not shown.

    I'm suspecting that the problem is in the Groups section of my vsct file.

    I'm setting the menu item as a child of IDM_VS_CTXT_CODEWIN

    Looking for a similar issue, I found the Microsoft VsMenus page: https://msdn.microsoft.com/en-us/library/bb163231(v=vs.100)

    In this page I didn't find another parent to my menu item.

    My goal is to build the active document's project directly from this menu item in context menu of VS's editor.

    Can someone help me?

    Thanks


    Márcio Alves Gonzalez Web programmer

    • Moved by Tina-Shi Friday, August 7, 2015 8:15 AM related to VSX
    Thursday, August 6, 2015 8:58 PM

Answers

  • There's a different context menu being displayed for .cshtml files.

    If you use the EnableVSIPLogging registry value, (HKEY_CURRENT_USER\SOFTWARE\Microsoft\VisualStudio\14.0\General), as described by this old article:  

    http://blogs.msdn.com/b/dr._ex/archive/2007/04/17/using-enablevsiplogging-to-identify-menus-and-commands-with-vs-2005-sp1.aspx

    You'll see there are two different context menus in use.

    .CS files use:

        Guid = {D309F791-903F-11D0-9EFC-00A0C911004F}
        GuidID = 4
        CmdID = 1037
        Type = 0x00000400
        Flags = 0x00000000

        NameLoc = Code Window

    and .CSHTML files use:

        Guid = {78F03954-2FB8-4087-8CE7-59D71710B3BB}
        GuidID = 395
        CmdID = 1
        Type = 0x00000400
        Flags = 0x00000000

        NameLoc = HTML Context

    So you need to modify your .vsct file accordingly.

    Sincerely,


    Ed Dore

    Tuesday, August 18, 2015 6:33 AM
  • Hi

    I'm guessing it was difficult because it looks like I may have given the wrong info. I tried this out on my VS2015 box, and using that EnableVSIPLogging registry trick, found the following details for that particular context menu:

        Guid = {78F03954-2FB8-4087-8CE7-59D71710B3BB}

        GuidID = 416

        CmdID = 1

        Type = 0x00000400

        Flags = 0x00000000

        NameLoc = HTML Context

    While the VSSDK publishes the most commonly used values, there are literally thousand of these identifiers that we don't know about. These particular values are not defined by the VSSDK, so you have to define them yourself.

    For example:

        <Groups>
          <Group guid="guidCommand1PackageCmdSet" id="MyMenuGroup" priority="0x0001">
            <Parent guid="guidHtmlCtxMenu" id="IDM_HTMLCTXMENU"/>
          </Group>
        </Groups>

      <Symbols>
         ....
        <GuidSymbol name="guidHtmlCtxMenu" value="{78F03954-2FB8-4087-8CE7-59D71710B3BB}">
          <IDSymbol name="IDM_HTMLCTXMENU" value="1" />
        </GuidSymbol>
        ....
      </Symbols>

    That should place your menu group onto the context menu that's displayed for .cshtml files.

    Sincerely,


    Ed Dore

    Wednesday, August 19, 2015 8:45 PM

All replies

  • Hi,

    Since this issue is related to the VSX, so we will move this case to the VSX forum, you will get better support.

    Best Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, August 7, 2015 8:14 AM
  • There's a different context menu being displayed for .cshtml files.

    If you use the EnableVSIPLogging registry value, (HKEY_CURRENT_USER\SOFTWARE\Microsoft\VisualStudio\14.0\General), as described by this old article:  

    http://blogs.msdn.com/b/dr._ex/archive/2007/04/17/using-enablevsiplogging-to-identify-menus-and-commands-with-vs-2005-sp1.aspx

    You'll see there are two different context menus in use.

    .CS files use:

        Guid = {D309F791-903F-11D0-9EFC-00A0C911004F}
        GuidID = 4
        CmdID = 1037
        Type = 0x00000400
        Flags = 0x00000000

        NameLoc = Code Window

    and .CSHTML files use:

        Guid = {78F03954-2FB8-4087-8CE7-59D71710B3BB}
        GuidID = 395
        CmdID = 1
        Type = 0x00000400
        Flags = 0x00000000

        NameLoc = HTML Context

    So you need to modify your .vsct file accordingly.

    Sincerely,


    Ed Dore

    Tuesday, August 18, 2015 6:33 AM
  • Hi Ed.

    Thanks for the response.

    This is another hard way to me.

    I don't know how I can get the correct parent id like "IDM_VS_CTXT_CODEWIN"

    My VS is running in with EnableVSIPLogging and I can get the information above, but I don't know how convert it to the right id.



    Can you help me with it?

    Thanks


    Márcio Alves Gonzalez Web programmer

    Tuesday, August 18, 2015 4:33 PM
  • Hi

    I'm guessing it was difficult because it looks like I may have given the wrong info. I tried this out on my VS2015 box, and using that EnableVSIPLogging registry trick, found the following details for that particular context menu:

        Guid = {78F03954-2FB8-4087-8CE7-59D71710B3BB}

        GuidID = 416

        CmdID = 1

        Type = 0x00000400

        Flags = 0x00000000

        NameLoc = HTML Context

    While the VSSDK publishes the most commonly used values, there are literally thousand of these identifiers that we don't know about. These particular values are not defined by the VSSDK, so you have to define them yourself.

    For example:

        <Groups>
          <Group guid="guidCommand1PackageCmdSet" id="MyMenuGroup" priority="0x0001">
            <Parent guid="guidHtmlCtxMenu" id="IDM_HTMLCTXMENU"/>
          </Group>
        </Groups>

      <Symbols>
         ....
        <GuidSymbol name="guidHtmlCtxMenu" value="{78F03954-2FB8-4087-8CE7-59D71710B3BB}">
          <IDSymbol name="IDM_HTMLCTXMENU" value="1" />
        </GuidSymbol>
        ....
      </Symbols>

    That should place your menu group onto the context menu that's displayed for .cshtml files.

    Sincerely,


    Ed Dore

    Wednesday, August 19, 2015 8:45 PM