Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 设置了INSTALLLOCATION的卸载时的CustomAction_C#_Wix - Fatal编程技术网

C# 设置了INSTALLLOCATION的卸载时的CustomAction

C# 设置了INSTALLLOCATION的卸载时的CustomAction,c#,wix,C#,Wix,我有一个windows服务,当它运行时,它会在windows服务的安装位置记录嵌套的日志文件。我正在尝试编写一个自定义操作,仅在卸载时删除所述文件。但是,当它运行时,我得到一个“INSTALLLOCATION是一个无效目录”错误。我假设在“After=“?”子句中运行自定义操作时需要更改,但我不确定应该更改什么 这是.wxs文件的当前代码 <Binary Id="CustomActionEXE" SourceFile="$(var.MyApp.TargetDir)MyApp.CA.dll"

我有一个windows服务,当它运行时,它会在windows服务的安装位置记录嵌套的日志文件。我正在尝试编写一个自定义操作,仅在卸载时删除所述文件。但是,当它运行时,我得到一个“INSTALLLOCATION是一个无效目录”错误。我假设在“After=“?”子句中运行自定义操作时需要更改,但我不确定应该更改什么

这是.wxs文件的当前代码

<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;
    }
}