Share via


Specifying Command Bars

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies.
This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

Command bars are specified in the <HostData> element of the recipe definition. These command bars equate to the command bars in the Visual Studio Solution Explorer that can display the recipe. They are denoted by the names that the Recipe Framework assigns to them. The command bars you can specify in the <HostData> element are the following:

  • Solution. This is the shortcut menu of the root of the solution in Solution Explorer.
  • Solution Folder. This is the shortcut menu of a solution folder in Solution Explorer.
  • Solution Add. This is the shortcut menu of the Add menu of the solution root in Solution Explorer.
  • Solution Folder Add. This is the shortcut menu of the Add menu of a solution folder in Solution Explorer.
  • Project. This is the shortcut menu of a single project in Solution Explorer.
  • Project Add. This is the shortcut menu of the Add menu of a project in Solution Explorer.
  • Folder. This is the shortcut menu of a folder inside a project in Solution Explorer.
  • Item. This is the shortcut menu of a single item in Solution Explorer.
  • Web Project. This is the shortcut menu of a single Web project in Solution Explorer.
  • Web Item. This is the shortcut menu of a single item in a Web project.
  • Web Folder. This is the shortcut menu of a Web folder in Solution Explorer.

The Recipe Framework has only been tested against the named command bars listed above. The schema contains the list of command bars that are explicitly supported by the Recipe Framework, and if you specify a command bar by name that is not supported by the Recipe Framework, the Guidance Package cannot be enabled, because of an XML validation error. However, it is possible to specify command bars that do not have names assigned to them by the Recipe Framework, using their Visual Studio identifiers and GUIDs. For command bars that are part of Visual Studio itself, these are obtained from the Visual Studio shell .ctc files that are included in the Visual Studio Industry Partner (VSIP) Program SDK. For more information, see https://msdn.microsoft.com/vstudio/extend/. If you do use command bars that the Recipe Framework has not been tested against, you will need to perform your own testing to ensure that they work correctly.

You can put commands directly in the solution element context menu, or you can put them in a cascading menu. You should put the following XML <HostData> element inside the <Recipe> elements to make the recipe reference appear directly in solution folder and project context many (as a command bar).

<HostData>
  <Icon ID="1046"/>
  <CommandBar Name="Solution Folder"/>
  <CommandBar Name="Project"/>
</HostData>

If you want a recipe command bar to appear in a cascading menu you need two <HostData> elements; one to define the cascading menu and the other to put the recipe command bar in that menu. The first <HostData> element is in the root <GuidancePackage> element of the Guidance Package Configuration file. The following XML <HostData> element defines a cascading menu that will in the context menu of the Solution Folder(s).

<GuidancePackage ... >
  <HostData>
    <Menu Name="CascadingMenuOne" Text="DoSomething">
      <CommandBar Name="Solution Folder"/>
    </Menu>
  ...
  </HostData>
...

The following <HostData> element placed in a <Recipe> element will make the corresponding recipe command bar appear in the cascading menu of the Solution Folder menu defined above.

<HostData>
  <CommandBar Menu=" CascadingMenuOne"/>
</HostData>

The configuration information only indicates that a command corresponding to a recipe has the potential to appear on the command bar. Whether the command actually appears on a selected element is determined by the Recipe Framework at run time. At run time, the Recipe Framework checks if one or more of the following is the case:

  • A bound recipe reference exists that is associated with the element.
  • An unbound reference exists that evaluates its TargetCondition as True on that element.

See also

Developing Recipes | Specifying Bound References | Specifying Unbound References | Writing Argument Value Providers | The AddMainClass Recipe | Using XInclude

Developing Recipes | Specifying Bound References | Specifying Unbound References | Writing Argument Value Providers | The AddMainClass Recipe | Using XInclude