How to showhide Commands conditionally in Visual Studio Extension

I am creating a Visual Studio Extension, which should perform following activities:

  1. On Right Click of Project, should show a Command.
  2. Specific command should be shown for specific project.

For Example:
enter image description here

I have added a Commands Menu where there are 2 Commands. But I want to show only ‘Command for Proj ABC’ when right clicked on ABC project and similarly ‘Command for Proj XYZ’ should be shown when right clicked on XYZ project.

Is this possible? How Can I achieve this?

You need to add DynamicVisibility CommandFlag in .vsct for your commands and set Visible status in your OnBeforeQueryStatus handler depending on which project is currently selected.

See Change the text of a menu command for an example.

Read more here: Source link