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獲得。

相關問題