如何从安装目录打开文件?

时间:2018-10-10 13:52:59

标签: wix windows-installer custom-action

将PATH传递给自定义操作

<Property Id="ModifyConfig" Value="PATH=[PATH]"/>
<CustomAction Id='ModifyConfig'
          BinaryKey="WebAppCA"
          DllEntry="ModifyConfig"
          Execute="deferred"
          Return="check"
          HideTarget="no"
          Impersonate="no"/>
<InstallExecuteSequence>
  <Custom Action="ModifyConfig" After="InstallFiles"></Custom>
</InstallExecuteSequence>

我的自定义操作

    [CustomAction]
    public static ActionResult ModifyConfig(Session session)
    {
            string PATH = session.CustomActionData["PATH"];

            FileInfo file = new FileInfo(PATH + "appsettings.json");
            session.Log("PATH: " + PATH);
            session.Log("Search for configuration file " + file.FullName);
     }

执行自定义操作时,我在日志中得到以下提示:

    PATH: C:\MyPath\
    Search for configuration file C:\WINDOWS\Installer\MSIE38D.tmp-\C:\MyPath\appsettings.json

如何处理以及如何获取文件?

编辑:效果很好-Execute =“ 立即”和After =“ InstallFinalize

<CustomAction Id='ModifyConfig'
          BinaryKey="WebAppCA"
          DllEntry="ModifConfig"
          Execute="immediate"
          Return="check"/>

<InstallExecuteSequence>
  <Custom Action="ModifyConfig" After="InstallFinalize"></Custom>
</InstallExecuteSequence>

0 个答案:

没有答案