It took me about 5 hours to do this.
There are two options: the Visual Studio add-in (or general add-in) and the Visual Studio package.
The package is much more complicated to give you much more control, but it is not needed for the context menu in the solution explorer.
So, a new project-> Other types of projects β Extensibility β Visual Studio Add-in.
Here's the walkthrough - Link
Also this one I followed some - Link
I recommend that you leave the option to add to the tool menu until the context menu works, or to provide a place to set the settings dialog box (if you do not click the Tool-> Tool page.
Here's the connection code:
_applicationObject = (DTE2)application; _addInInstance = (AddIn)addInInst; if (connectMode == ext_ConnectMode.ext_cm_UISetup) { object[] contextGUIDS = new object[] { }; Commands2 commands = (Commands2)_applicationObject.Commands; string toolsMenuName = "Tools";
This code checks to see if what the user has selected, for example, the project:
private Project GetProject() { if (_applicationObject.Solution == null || _applicationObject.Solution.Projects == null || _applicationObject.Solution.Projects.Count < 1) return null; if (_applicationObject.SelectedItems.Count == 1 && _applicationObject.SelectedItems.Item(1).Project != null) return _applicationObject.SelectedItems.Item(1).Project; return null; }
Please note that some string names in your code should match, and I'm not sure which ones they haven't done yet, since I just did it yesterday.
Maslow Jun 14 '10 at 18:34 2010-06-14 18:34
source share