Wix5 菜鸟问题;如何添加基于安装信息创建文件及其内容的自定义操作?

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

在Wix5中, 我尝试添加一个在安装结束时运行的自定义操作,并创建一个内容为安装目录路径的文件 我尝试了以下方法:

<Fragment>
  <ComponentGroup Id="ExampleComponents" Directory="INSTALLFOLDER">

<ComponentGroupRef Id="Package1"/>

  </ComponentGroup>
 <Binary Id="vbsexecutionTest" SourceFile="createFile.vbs"/>
 <Property Id="CustomActionData" Value="CIRO"/>
 <CustomAction Id="LaunchMyApp" BinaryRef="vbsexecutionTest"
                  VBScriptCall=""                   
            Execute="deferred" Return="check"  />
 <!-- Define a custom action that launches the embedded binary -->
 <InstallExecuteSequence>
  <Custom Action="LaunchMyApp" After="InstallFiles"/>
 </InstallExecuteSequence>
</Fragment>

但是我没有找到传递参数的方法...

也许 vb 脚本不是正确的方法?

wix5
1个回答
0
投票

终于找到正确的方法了:

首先非常感谢这个网站:
如何使用命令行参数将自定义操作传递给 WIX 安装程序

所以正确的方法是创建DLL 特别是自定义操作一个

自定义操作项目参考 DTF 创建文件

using WixToolset.Dtf.WindowsInstaller;

cf WixToolset.Dtf.WindowsInstaller 命名空间
通过这样的配置,wsx 文件内的属性可以通过 session 语句在 DLL 中可见
 session["INSTALLFOLDER"]
例如,使用 Id INSTALLFOLDER 读取属性值

然后将 CustomActionCode.CA.dll 作为二进制文件添加到您的 wsx 中,并...按如下方式创建自定义操作

<CustomAction 
       Id="LaunchMyApp" 
       BinaryRef="* ID of the binary *"
       DllEntry="* static public function defined in the DLL 
                  and tagged in the DLL as  [CustomAction] *"           
       Return="check"  
/>


感谢 Christopher 以及它在 通过 WiX 使用的 C# 中的自定义操作失败并出现错误 1154\

中的答案
© www.soinside.com 2019 - 2024. All rights reserved.