代码之家  ›  专栏  ›  技术社区  ›  JontyMC

VS加载项:在web应用程序上添加上下文按钮

  •  0
  • JontyMC  · 技术社区  · 15 年前

    我正在和VisualStudio(2008)外接程序混在一起。我希望能够在所有web应用程序上下文菜单中添加一个按钮(该按钮将基于web部署工具的共享存档为网站设置IIS)。

    public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
    

    applicationObject=(DTE2)应用程序;

    if (connectMode == ext_ConnectMode.ext_cm_UISetup) {
        var contextGuids = new Object[] {};
        var iisSetupCommand = applicationObject.Commands.AddNamedCommand(
            addInInstance,
            CommandNameSetupIis,
            "Setup IIS",
            "Create the bindings in IIS for the website. Requires an IIS folder in the project root with the archive xml files for the website.",
            true,
            52,
            ref contextGuids,
            (int) vsCommandStatus.vsCommandStatusSupported + (int) vsCommandStatus.vsCommandStatusEnabled
            );
    
        var commandBars = (CommandBars) applicationObject.CommandBars;
        var projectMenu = commandBars["Project"];
        iisSetupCommand.AddControl(projectMenu, projectMenu.Controls.Count + 1);
    }
    

    问题2是我不知道如何只显示web应用程序项目的按钮。

    http://dotnetslackers.com/articles/vs_addin/Lessons_learned_from_Copy_to_Html_Add_in.aspx

    1 回复  |  直到 15 年前
        1
  •  0
  •   JontyMC    15 年前

    问题1:覆盖QueryStatus并将状态设置为vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled