0
我寫了一個樣本WiX項目,其中我正在嘗試在安裝時保存項目文件,並在卸載過程中稍後刪除這些文件。我已經編寫了自定義操作來實現這一點。以下是代碼。參數沒有傳遞到WiX中的延遲自定義操作
這裏,UninstallCustomAction是刪除安裝目錄的自定義操作。這是一個推遲的操作,我試圖使用SetCustomActionDataValue自定義操作將installFolder路徑傳遞給它。出於某種原因,我無法在會話的CustomActionData中訪問這些變量。我在這裏錯過了什麼?需要
<CustomAction Id="SetCustomActionDataValue"
Return="check"
Property="Itp.Configurator.WixCustomAction"
Value="InstallFolder=[INSTALLFOLDER]" />
<CustomAction Id="UninstallCustomAction"
Return="check"
Execute="deferred"
BinaryKey="DTD.LCTOnline.Wix.CustomActions.CA.dll"
DllEntry="UninstallCustomAction"
Impersonate="no"
HideTarget="no"/>
<InstallExecuteSequence>
<Custom Action="SetCustomActionDataValue"
Before="UninstallCustomAction"></Custom>
<Custom Action="UninstallCustomAction"
Before="InstallFinalize">Installed OR UPGRADINGPRODUCTCODE</Custom>
</InstallExecuteSequence>
[CustomAction]
public static ActionResult UninstallCustomAction(Session session)
{
try
{
System.Diagnostics.Debugger.Launch();
session.Log("Begin Remove Files");
Directory.Delete(path,true);
session.Log("End Remove Files");
}
catch (Exception ex)
{
session.Log("ERROR in deleting Files", ex.ToString());
return ActionResult.Failure;
}
return ActionResult.Success;
}