Search code examples
visual-studio-2017vs-extensibility

VS 2017 Extension - Add custom Solution Menu item


I am trying to add a menu item in the solution context menu. So when I do right click on the solution node I want to add a menu item. When I am clicking on the menu item I want to parse all the projects and do some checks.

I am adding the menu but into the toolbar:

    private SecondCommand(AsyncPackage package, OleMenuCommandService commandService)
    {
        this.package = package ?? throw new ArgumentNullException(nameof(package));
        commandService = commandService ?? throw new ArgumentNullException(nameof(commandService));

        var menuCommandID = new CommandID(CommandSet, CommandId);
        var menuItem = new MenuCommand(this.MenuItemCallback, menuCommandID);
        commandService.AddCommand(menuItem);
    }

How can I access to the solution context menu? The comandService is the VS main toolbar.


Solution

  • See my CommandSolutionContextMenu sample