Question

We are developing addin for Visual Studio. It creates items in Solution Explorer context menu. The problem is when we remove the addin, menu item is still there but without icon. When I click on it, VS propose to remove the command. See screenshot. enter image description here

How should they be uninstalled to remove the command?
At the moment I just remove the addin file from "Visual Studio 2012\Addins" folder during uninstall.
I'm using class Connect : IDTExtensibility2

Was it helpful?

Solution

One option is to run a .vbs script on uninstall with following commands:

Set dte = CreateObject("VisualStudio.DTE.11.0")
dte.Commands.Item("your_command_name").Delete
dte.Quit

OTHER TIPS

I've found help here.
In .addin file:

<CommandPreload>0</CommandPreload>

In Connect class:

    public void OnDisconnection(ext_DisconnectMode disconnectMode, ref Array custom)
    {
        switch (disconnectMode)
        {
            case ext_DisconnectMode.ext_dm_HostShutdown:
            case ext_DisconnectMode.ext_dm_UserClosed:
                Command command = applicationObject.Commands.Item(addInInstance.ProgID + "." + addWebDAVServerCommandId);
                if (command != null)
                {
                    command.Delete();
                }
                break;
        }
    }

    public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
    {
        applicationObject = (DTE2)application;
        addInInstance = (AddIn)addInInst;

        // We should never get here, this is temporary UI
        if (connectMode == ext_ConnectMode.ext_cm_UISetup)
            return;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top