我编写了一个示例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;
}