WIX Custom Action的使用

为实现一些WIX自带的方法实现不了的功能,需要用到Custom Action。

本章会分别描述如何定义及使用CustomAction.

1. Custom Action的定义方式

在VS2012,下载好对应的WIX Toolset插件后,可在New Project里使用C#, vb或C++生成custom action。

定义具体方法functionName1。以下例子为给一个<Property/>赋值。

        [CustomAction]
        public static ActionResult functionName1(Session session)
        {
            session["propertyId1"] = "new Value";
            return ActionResult.Success;
        }
build project -> 把xxxxx.CA.dll文件引用到WIX项目中。

另外,dll由于调试不了,使用log4net来进行查看log。配置方法参考

http://www.cnblogs.com/zhangchenliang/p/4546352.html

2. 使用方法

使用以下语句把引用文件加到wxs中,位置是 <Product> </Product>下一层的标签: 

      <Binary Id="customActionFileId" SourceFile="xxxxx.CA.dll" />
然后,对每个要用到的具体方法,加以下语句:

      <CustomAction Id="functionName1" BinaryKey="customActionFileId" DllEntry="functionName1" Execute="immediate" Return="check" />
然后,就可以进行调用。

通过以下语句,就可以在按钮点击事件中触发。

<Publish Dialog="xxxxxxDlg" Control="TypicalButton" Event="DoAction" Value="functionName1">1</Publish>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值