0

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

Community
  • 1
  • 1
Taras Kozubski
  • 1,854
  • 1
  • 20
  • 33

2 Answers2

1

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
Sergey Vlasov
  • 26,641
  • 3
  • 64
  • 66
  • Can I run .vbs script in Visual Studio 2012? I heard vbs script was removed from Visual Studio 2012. – P-P Mar 05 '14 at 09:05
  • @P-P .vbs scripts are executed outside VS and work for VS 2012 too. It is internal VB Visual Studio macros that are not available from VS 2012+ (though you can now use Visual Commander to run them.) – Sergey Vlasov Mar 06 '14 at 08:27
0

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;
Taras Kozubski
  • 1,854
  • 1
  • 20
  • 33