Wix:在自定义操作中写入文件

rhe*_*980 4 c# custom-action wix

我遇到了wix和托管自定义操作的问题:在我的自定义操作中,我创建了一个文件并将其保存在INSTALLLOCATION路径中.它似乎工作,没有抛出异常.但是在安装之后,刚刚创建的文件在INSTALLLOCATION中不存在.

维克斯 - 文件:

<CustomAction Id="SetInstallPath" Property="CreateTimeStamp" Value="[INSTALLLOCATION]"
   Execute="immediate"/>
<CustomAction Id="CreateTimeStamp" BinaryKey="SetupActions.dll"  
   DllEntry="CreateTimeStampFile" Execute="deferred" Return="check"/>
<InstallExecuteSequence>
  <Custom Action="SetInstallPath" Before="InstallFinalize"/>
  <Custom Action="CreateTimeStamp" Before="InstallFinalize"/>
</InstallExecuteSequence>
Run Code Online (Sandbox Code Playgroud)

定制操作-了Methode:

...
var keys = new string[session.CustomActionData.Keys.Count];
session.CustomActionData.Keys.CopyTo(keys, 0);
var cad = keys[0];
var filepath = cad + "myfile.xml";
File.Create(filepath);
...
Run Code Online (Sandbox Code Playgroud)

有人有想法吗?

编辑:在Scott Boettger的帖子后编辑了wix文件内容.

Cos*_*rvu 7

我不认为你的配置是正确的.以下是一些问题:

  1. 您不应该在InstallExecuteSequence中使用私有属性(CREATE_TIME_STAMP优于CreateTimeStamp,因为它是公共属性).
  2. 您正在设置CreateTimeStamp属性并在自定义操作中读取CustomActionData.您应该将CustomActionData属性设置为INSTALLLOCATION路径.
  3. 由于您的自定义操作是在安装文件夹中创建文件,因此它应该作为延迟运行,并且Impersonate属性应设置为"no".这样它就有足够的权限来创建文件.

尝试进行这些修改,看看问题是否仍然存在.


Sco*_*ger 6

我相信您的自定义操作需要介于InstallInitialize和InstallFinalize之间.试试这个:

<InstallExecuteSequence>
  <Custom Action="SetInstallPath" After="InstallInitialize"/>
  <Custom Action="CreateTimeStamp" Before="InstallFinalize"/>
</InstallExecuteSequence>
Run Code Online (Sandbox Code Playgroud)