2012-11-14 171 views
3

我遇到了Wix自定義操作未執行的問題。即使自定義操作返回ActionResult.Success,安裝程序也會不斷自動回滾。WiX自定義操作未執行

自定義操作(C#)在維克斯

[CustomAction] 
public static ActionResult SetPermissionsToAppDataFolder(Session session) 
{ 
    return ActionResult.Success; 
} 

自定義動作定義

<!-- Custom Action --> 
<Binary Id="CustomActionLibrary" SourceFile="$(var.CustomActionFolder)InstallerCustomActions.CA.dll" /> 
<CustomAction Id="CustomActionInstallDirectoryPermission" 
       BinaryKey="CustomActionLibrary" 
       DllEntry="SetPermissionsToAppDataFolder" 
       Execute="deferred" 
       Return="check" /> 

安裝程序調用自定義操作

<!-- Install Sequences --> 
<InstallExecuteSequence> 
     <Custom Action="CustomActionInstallDirectoryPermission" Before="InstallFinalize">NOT Installed</Custom> 
</InstallExecuteSequence> 

安裝程序編譯良好,因此找到自定義操作庫文件沒有問題。問題在於安裝程序在回滾之前進入安裝的最後階段。當我們在安裝序列中刪除對自定義操作的調用時,安裝程​​序將完成。

根據我的理解,自定義操作CA.dll被嵌入到最終的安裝程序中。最初我以爲CA.dll需要與安裝程序一起發佈,但後來發現安裝程序將其編譯到最終的.msi文件中。

我有「有線」使用代碼自定義操作庫在發現: http://www.codeproject.com/Articles/132918/Creating-Custom-Action-for-WIX-Written-in-Managed

不管我做什麼,我不能讓安裝程序完成,即使在自定義操作返回「成功」。任何幫助表示讚賞。

+1

執行'MSIEXEC/I yourinstaller.msi/L log.txt'和尋找輸出的'log.txt'文件中產生的任何錯誤。 –

+0

會相對於安裝程序創建日誌文件嗎? –

+0

日誌文件將在執行'msiexec'的目錄中創建。也許像'C:\ Users \ Rupert Puxton \ Documents \ Visual Studio 2010 \ Projects \ My Project \ Installer \ bin \ Release',或類似的東西。 –

回答

1

對於任何與WiX苦苦掙扎的人而言,

幾點建議:

1)你有沒有嘗試添加Debugger.Launch()到你的CustomAction第一行代碼(即上述返回ActionResult.Success;)?如果你沒有得到一個對話框要求啓動一個調試器,那麼你知道你的WiX腳本沒有正確引用你的CA.dll或者它的調用有問題。

2)如果你正在使用片段和CustomAction元素坐在裏面他們,儘量把他們,並把他們產品元素來代替。

3)如果你打算使用延遲執行,你在你的CustomAction試圖冒充= 「無」屬性