2013-07-03 50 views
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; 
} 

回答

2

没有自定义操作:使用RemoveFoldersEx在WixUtilExtension。