C# 设置了INSTALLLOCATION的卸载时的CustomAction
我有一个windows服务,当它运行时,它会在windows服务的安装位置记录嵌套的日志文件。我正在尝试编写一个自定义操作,仅在卸载时删除所述文件。但是,当它运行时,我得到一个“INSTALLLOCATION是一个无效目录”错误。我假设在“After=“?”子句中运行自定义操作时需要更改,但我不确定应该更改什么 这是.wxs文件的当前代码C# 设置了INSTALLLOCATION的卸载时的CustomAction,c#,wix,C#,Wix,我有一个windows服务,当它运行时,它会在windows服务的安装位置记录嵌套的日志文件。我正在尝试编写一个自定义操作,仅在卸载时删除所述文件。但是,当它运行时,我得到一个“INSTALLLOCATION是一个无效目录”错误。我假设在“After=“?”子句中运行自定义操作时需要更改,但我不确定应该更改什么 这是.wxs文件的当前代码 <Binary Id="CustomActionEXE" SourceFile="$(var.MyApp.TargetDir)MyApp.CA.dll"
<Binary Id="CustomActionEXE" SourceFile="$(var.MyApp.TargetDir)MyApp.CA.dll" />
<CustomAction Id="RemoveLogFilesCA" BinaryKey="CustomActionEXE" DllEntry="RemoveLogFiles" Execute="immediate" Return="check"/>
<InstallExecuteSequence>
<Custom Action="RemoveLogFilesCA" After="RemoveFiles">
(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")
</Custom>
</InstallExecuteSequence>
首先,我建议日志文件是用户数据,1)不应在卸载时删除,2)不应保存在ProgramFiles文件夹下。ProgramData将是一个更好的位置 如果您必须递归删除这些文件,请不要用您自己的CA重新发明轮子。请改用
public class CustomActions
{
[CustomAction]
public static ActionResult RemoveLogFiles(Session session)
{
// Error here: "INSTALLLOCATION is an invalid directory", value not set when the custom action is being executed After="RemoveFiles"
//string installLocation = session.GetTargetPath("INSTALLLOCATION");
return ActionResult.Success;
}
}