[英]displaying a WPF Window from a System.Configuration.Install.Installer class
[英]How to make a System.Configuration.Install.Installer to get a variable from the Setup project?
我的解決方案中有2個項目
Windows服務
它的安裝項目
我需要我的ProjectInstaller : System.Configuration.Install.Installer
的方法調用OnAfterInstall來從安裝項目中獲取ProductName
。 我怎么做?
在安裝項目中右鍵單擊項目,然后選擇查看>自定義操作。 添加自定義操作。 現在選擇Add Output,選擇您的Web服務項目,然后單擊OK。
現在選擇自定義操作並將CustomActionData
屬性設置為包含類似/ProductName=[PRODUCTNAME] /whateveryouwant=[Whateveryouwant]
(請注意,這些是鍵值對;即,要訪問產品名稱, ProductName
是鍵和值是PRODUCTNAME
)。
請注意, CustomActionData
包含將傳遞給安裝程序類的參數。 PRODUCTNAME
是與用戶界面對話框中的輸入控件關聯的屬性名稱,因此在您的情況下,您將在yor安裝程序中提示用戶輸入Product Name。 所以標簽是“產品名稱”,相應的屬性應該設置為PRODUCTNAME
(顯然你可以改變它,但最重要的是要注意的是UI屬性名稱必須與CustomActionData
的屬性名稱相同)這個例子工作。
現在,在安裝程序類中,您可以通過執行獲取產品名稱
public override void Install(IDictionary stateSaver)
{
// If you need to debug this installer class, uncomment the line below
//System.Diagnostics.Debugger.Break();
string productName = Context.Parameters["ProductName"].Trim();
string whateveryouwant = Context.Parameters["whateveryouwant"].Trim();
}
請注意我添加了注釋代碼//System.Diagnostics.Debugger.Break();
您可以在其中發表評論,以便您可以調試安裝程序類。
希望這可以幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.