2009-06-16 57 views
0

我正在搞乱Visual Studio(2008)加载项。我希望能够在所有的Web应用程序上下文菜单中添加一个按钮(这将基于Web部署工具中的共享存档为网站设置IIS)。VS加载项:在Web应用程序中添加上下文按钮

据我得为能够加入项目上下文菜单中的上下文项:

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

{ 的applicationObject =(DTE2)申请书; addInInstance =(AddIn)addInInst;

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); 
} 

}

这工作,但我无法进一步得到。

问题1点击时按钮消失。

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

问题3我需要编写代码来获取iis存档,当前项目目录路径和项目名称以创建IIS绑定,然后使用这些设置运行Web部署工具。

此加载项是非常钝的。我尽可能多地搜索并阅读大部分(糟糕的)msdn文档。我发现的最好的信息是:http://dotnetslackers.com/articles/vs_addin/Lessons_learned_from_Copy_to_Html_Add_in.aspx

任何人都可以帮忙吗?

回答

0

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

问题2:我不认为这是可能的。可以获取项目类型,但只有点击按钮后(QueryStatus只有在按钮被点击一次后才会触发)。

问题3:项目路径可通过connect.ApplicationObject.ActiveSolutionProjects获得。

相关问题