C# 在CustomAction中的WiX安装期间尝试读取文件,然后写入文件

C# 在CustomAction中的WiX安装期间尝试读取文件,然后写入文件,c#,session,wix,C#,Session,Wix,更新 这个问题现在已经解决了,所以我为未来的读者更新了这篇文章 这件事让我很难受。关于这些有很多问题,但我被卡住了 我的目标是执行两个步骤: 1) 读取msi附带的物理文件。换句话说,将有三个文件setup.exe、test.msi和specialFile.txt 2) 在安装过程中,我想在安装路径中创建一个新文件。C:\Program Files\MyCompany\MyApplication\newFile.txt 步骤2中的文件是通过从步骤1的specialFile.txt中读取某些内容创

更新

这个问题现在已经解决了,所以我为未来的读者更新了这篇文章

这件事让我很难受。关于这些有很多问题,但我被卡住了

我的目标是执行两个步骤:

1) 读取msi附带的物理文件。换句话说,将有三个文件setup.exe、test.msi和specialFile.txt

2) 在安装过程中,我想在安装路径中创建一个新文件。C:\Program Files\MyCompany\MyApplication\newFile.txt

步骤2中的文件是通过从步骤1的specialFile.txt中读取某些内容创建的

我的问题是在WiX设置的模糊组合中导航,使我能够读取会话变量,并拥有足够高的权限来写出文件。这并不容易

解决方案如下:

<Binary Id="MyCustomAction.CA.dll" SourceFile="path\to\MyCustomAction.CA.dll" />
<CustomAction Id="MyActionsName"
    Return="check"
    Execute="deferred"
    BinaryKey="MyCustomAction.CA.dll"
    DllEntry="MyCustomAction"
    Impersonate="no"/>

    <CustomAction Id="CustomAction1"
        Property="MyActionsName"
        Value="INSTALLFOLDER=[Get_This_From_Your_Directory_Tag];SOURCEDIR=[SourceDir]"/>

<InstallExecuteSequence> 
    <Custom Action="CustomAction1" Before="MyActionsName" />
    <Custom Action="MyActionsName" Before="InstallFinalize">NOT Installed AND NOT PATCH</Custom>
</InstallExecuteSequence>       
其他有用的参考资料:

<Binary Id="MyCustomAction.CA.dll" SourceFile="path\to\MyCustomAction.CA.dll" />
<CustomAction Id="MyActionsName"
    Return="check"
    Execute="deferred"
    BinaryKey="MyCustomAction.CA.dll"
    DllEntry="MyCustomAction"
    Impersonate="no"/>

    <CustomAction Id="CustomAction1"
        Property="MyActionsName"
        Value="INSTALLFOLDER=[Get_This_From_Your_Directory_Tag];SOURCEDIR=[SourceDir]"/>

<InstallExecuteSequence> 
    <Custom Action="CustomAction1" Before="MyActionsName" />
    <Custom Action="MyActionsName" Before="InstallFinalize">NOT Installed AND NOT PATCH</Custom>
</InstallExecuteSequence>       
以及关于延迟操作中的自定义属性

显示如何在不使用会话[“SourceDir”]的情况下读取SourceDir,因为自定义操作已延迟