WIX:“安装文件”后,CustomAction找不到文件]]

问题描述 投票:1回答:1

我目前正在使用CustomAction库来读写INI(在C:\ Windows外部)和XML文件。我已经查看了this SO question,但是建议的答案对我的问题没有帮助。我尝试执行的CustomAction(用于从INI文件读取值)定义为

<CustomAction Id="MyCustomAction" 
              Execute="deferred"
              Impersonate="no"
              Return="ignore"
              BinaryKey="MyCALibrary.CA.dll"
              DllEntry="MyCustomActionEntry" />

并安排为

<InstallExecuteSequence>
   <Custom Action="MyCustomAction" After="InstallFiles">
     <![CDATA[NOT Installed AND NOT PATCH]]>
   </Custom>
</InstallExecuteSequence>

由于是延迟动作,它通过属性接收数据:

   <Property Id="MyCustomAction"
              Value="File=[INSTALLDIR]cfg\MyConfig.ini;Section=MyConfig;Key=MyKey"/>

我的CustomAction的(C#)实现如下所示:

    [CustomAction]
    public static ActionResult MyCustomActionEntry(Session session)
    {
      try
      {
        session.Log("Begin MyCustomActionEntry");
        CustomActionData data = session.CustomActionData;

        session.Log($"Data: '{data}'.");

        string fileName = data["File"];
        string sectionName = data["Section"];
        string keyName = data["Key"];

        // ... check if all properties are set
        // ... removed for brevity

        session.Log($"- Parametrization: (File={fileName}; Section={sectionName}; Key={keyName}.");

        if(File.Exists(fileName))
        {
          session.Log("File found on disk.");
        }
        else
        {
          session.Log("File NOT found on disk.");
        }

        // ... actual INI Access - F A I L S

      } 
      catch(Exception ex)
      {
        //... handle any errors
      }
    }

使用Orca,我发现CustomAction最有可能是正确安排的-表InstallExecuteSequence显示:

...
InstallFiles   4000
...
MyCustomAction 4001
...

当然,我现在在安装日志中查看了提示。日志显示:(我想是immediate

阶段):
Action ended <time>: InstallFiles. Return value 1.
MSI (s) (F8:98) <time>: Doing action: MyCustomAction
Action start <time>: MyCustomAction.
Action ended <time>: MyCustomAction. Return value 1.

对于我认为将是deferred

阶段(在日志中进一步介绍):
MSI (s) (F8:98) <time>: Executing op: FileCopy(SourceName=qjlzmwkb.ini|MyConfig.ini,SourceCabKey=<key>,DestName=MyConfig.ini,...,InstallMode=58982400,...)
MSI (s) (F8:98) <time>: File: C:\tmp\MyApp\cfg\MyConfig.ini;    To be installed;    Won't patch;    No existing file
MSI (s) (F8:98) <time>: Source for file '<key>' is compressed
...
Begin MyCustomActionEntry
...
Data: 'File=C:\tmp\MyApp\cfg\MyConfig.ini;Section=MyConfig;Key=MyKey'.
...
- Parametrization: (File=C:\tmp\MyApp\cfg\MyConfig.ini; Section=MyConfig; Key=MyKey).
...
File NOT found on disk.

安装程序完成后,文件正好位于我所指的位置-自定义操作中引用的位置。

我假定在执行阶段的延迟阶段中,在InstallFiles之后,已安装的文件应在磁盘上可用,以便任何CustomAction均可访问。有没有其他人观察到类似的行为,可以给我提示其他方法吗?

我目前正在使用CustomAction库来读写INI(在C:\ Windows外部)和XML文件。我已经看过这个问题了,但是建议的答案对我的问题没有帮助。...

wix windows-installer custom-action
1个回答
0
投票

[INI

© www.soinside.com 2019 - 2024. All rights reserved.