我有一個使用CAQuietExec的自定義操作,在某些情況下失敗 - 唯一的錯誤消息出現在日誌文件中,這對開發人員來說是非常好的,對最終用戶無用。我的目標是在回滾安裝之前捕獲失敗的操作並預設標準錯誤消息。Wix CustomAction dll
要做到這一點,基於我的研究,我決定我需要編寫自己的自定義動作DLL,所以我開始關注this tutorial。在這個階段,我的dll只記錄一條測試消息並嘗試將錯誤消息傳回對話屏幕。但是,當我編譯並運行msi時,根本沒有任何反應 - 沒有記錄,也沒有任何錯誤消息。看看Orca中的msi,它對我來說看起來不錯 - 但正如你可以在下面看到的那樣,測試dll應該會導致安裝在實際運行時立即中止,而不會立即中止。
所以我的問題:我是否會以最好的方式向用戶提供反饋?如果是這樣,任何想法爲什麼我的自定義操作沒有運行?
感謝
CustomAction.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Deployment.WindowsInstaller;
using System.Collections.ObjectModel;
using System.Management.Automation;
namespace MyCustomActions
{
public class CustomActions
{
[CustomAction]
public static ActionResult CustomAction1(Session session)
{
session.Log("Begin CustomAction1");
DisplayMSIError(session, "A test message");
return ActionResult.Failure;
}
static void DisplayMSIError(Session session, String msg)
{
var r = new Record();
r.SetString(0, msg);
session.Message(InstallMessage.Error, r);
}
}
}
Product.wxs
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="MyPackage" Language="1033" Version="0.0.0.1" Manufacturer="Acme" UpgradeCode="GUID">
<Package InstallerVersion="300" Compressed="yes" InstallScope="perMachine" />
<Binary Id="MyCustomActions.CA.dll" src="MyCustomActions\MyCustomActions.CA.dll" />
<CustomAction Id="MyCustomActionsTest"
Return="check"
Execute="immediate"
BinaryKey="MyCustomActions.CA.dll"
DllEntry="CustomAction1" />
<InstallExecuteSequence>
<Custom Action="MyCustomActionsTest" After="LaunchConditions" />
...
</InstallExecuteSequence>
</Product>
</Wix>
我想,也許你只是需要多一點理解的方式失速作品。其中一個重要思想是你遇到的一個問題:InstallUISequence先運行,然後執行序列,所以你的CA在標準的UI對話框之後。 session.message沒有錯誤告訴用戶錯誤。 – PhilDW 2014-10-06 17:10:29