The questions of how to create a toolbar, a top menu, a sub menu, an entry on a context menu, etc. appear from time to time on the forums, so I have created a bunch of samples on GitHub:
visualstudioextensibility/VSX-Samples
They use what I consider best practice: the use of the CommandPlacements section in the .vsct file for centralized place to set parent-child relationships.
The code samples are the following:
HOWTO: Create a Visual Studio toolbar
Demonstrates how to create a toolbar.
HOWTO: Create a Visual Studio top menu
Demonstrates how to create a top menu.
HOWTO: Create Visual Studio commands on a submenu
Demonstrates the use of the CommandPlacements section of the .vsct file to place a command inside a new group on a submenu inside a new group on the Solution context menu and on the Standard toolbar.
HOWTO: Create a Visual Studio command on the Solution context menu
Demonstrates the use of the CommandPlacements section of the .vsct file to place a command inside a new group inside the Solution context menu.
HOWTO: Create a Visual Studio command on the project context menu
Demonstrates the use of the CommandPlacements section of the .vsct file to place a command inside a new group on the context menu of a Windows project, Web project, or multiple projects selected.
HOWTO: Create a Visual Studio command on the file context menu
Demonstrates the use of the CommandPlacements section of the .vsct file to place a command inside a new group on the context menu of a file or multiple files (belonging to the same project, or to different projects).
HOWTO: Create a Visual Studio command on the code window context menu
Demonstrates the use of the CommandPlacements section of the .vsct file to place a command inside a new group on the code window context menu.
I attempted to try the “CommandCodeWindowContextMenu” solution, but when I try and run it in Visual Studio (2015 Professional), I get an error indicating “A project with an Output Type of Class Library cannot be started directly.” I’m pretty sure I’ve been developing extensions for a while and thought that this would fall into that category. Perhaps I overlooked something, but could not find anything on this page that would indicate I should do something different.
There are a couple of additional steps to get this to work:
Right click the project (CommandCodeWindowContextMenu)->Properties->Debug->
Select ‘Start external program: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe’
Command line arguments: /rootsuffix Exp
Note that this is for VS 2015 professional. The actual changes may vary slightly with different VS versions.
My web based application uses the Microsoft menu control. TRhe chevron on the main menu items points to the right. How do I get it to point downwards?
How do I apply these command to my project such as command on file text menu.
Thank you!