I'm currently writing a plugin/extension for Visual Studio and I'd like to be able to find an existing menu command and hide it. Specifically, I want to find the Rebuild commands in the context menus and hide or disable them. It looks like I have access to the command IDs: https://msdn.microsoft.com/en-us/library/microsoft.visualstudio.vsconstants.vsstd2kcmdid(v=vs.140).aspx
And using OleMenuCommandService there is a FindCommand but it returns NULL. Here is what I'm currently trying:
OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
if ( null != mcs )
{
MenuCommand rebuildCommand = mcs.FindCommand(new CommandID(
Microsoft.VisualStudio.VSConstants.UICONTEXT_SolutionHasSingleProject,
(int)Microsoft.VisualStudio.VSConstants.VSStd97CmdID.RebuildCtx) );
// rebuildCommand is NULL
}
Any ideas on the way to do this?