WiX Custom Action 的deferred !
来源:互联网 发布:2017日剧 知乎 编辑:程序博客网 时间:2024/06/07 09:23
WiX Custom Action 的deferred !
当使用Custom Action 时,时常会需要按照一定的顺序去执行相应的Custom Action,这时需要使Execute="deferred" 然而在执行相应的脚本时,去获取相应的session时却会为空或不存在。
例如:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2003/01/wi">
<Product Id="{94A35E02-D48F-48F1-AC1A-23F62489BBF4}"
Name="Minimal Windows Installer Sample"
Language="1033"
Codepage="1252"
Version="1.0.0"
Manufacturer="Acme Corporation"
UpgradeCode="{74069BA4-1D1C-4252-A074-B2EC0C746403}">
<Package Id="{4C159FD5-135E-42DE-B36E-22DDDCBA3DCF}"
Description="Minimal Windows Installer Sample"
Comments="This installer database contains the logic and data required to install [ProductName]."
InstallerVersion="200"
Languages="1033"
SummaryCodepage="1252"
Platforms="Intel"
ReadOnly="no"
Compressed="yes"
AdminImage="no"
Keywords="Installer"
ShortNames ="no"
Manufacturer="Acme Corporation" />
<Media Id="1" Cabinet="CAB001.cab" EmbedCab="yes" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLDIR" Name="Minimal" LongName="MinimalInstallation">
<Component Id="Component1"
Guid="{A77C5B06-132D-4884-8E17-EA10A83C812D}">
<File Id="ReadMe" DiskId="1" Name="Readme.txt" Source="Readme.txt" Vital="yes" KeyPath="yes" />
</Component>
</Directory>
</Directory>
</Directory>
<Property Id="TESTPROPERTY" Value="Hello" />
<CustomAction Id="ShowProperty" Script="vbscript" Execute="deferred">
<![CDATA[
MsgBox Session.Property("TESTPROPERTY")
]]>
</CustomAction>
<InstallExecuteSequence>
<Custom Action="ShowProperty" Before="InstallFinalize">Not Installed</Custom>
</InstallExecuteSequence>
<Feature Id="Feature1"
Title="Feature1 title"
Description="Feature1 description"
Level="1"
ConfigurableDirectory="INSTALLDIR" >
<ComponentRef Id="Component1" />
</Feature>
</Product>
</Wix>
执行后会发现弹出的对话框为空。而如果使用Execute="immediate"(缺省设置)时会发现会弹出相应的目录。
这是因为延迟方式的Custom Action 在获取相应的session时,session已经销毁了,
则延迟方式的Custom Action 只能使用以下三种property:
ProductCode
UserSID
CustomActionData
使用customActionData方式(即先将需要的property保存):
<Property Id="TESTPROPERTY" Value="Hello" />
<CustomAction Id="ShowProperty" Script="vbscript" Execute="deferred">
<![CDATA[
MsgBox Session.Property("CustomActionData")
]]>
</CustomAction>
<CustomAction Id="SetPropertyForShowProperty"
Property="ShowProperty" Value="[TESTPROPERTY]" />
<InstallExecuteSequence>
<Custom Action="SetPropertyForShowProperty" Before="InstallInitialize">Not Installed</Custom>
<Custom Action="ShowProperty" Before="InstallFinalize">Not Installed</Custom>
</InstallExecuteSequence>
如需要多个property:
<Property Id="TESTPROPERTY" Value="Hello" />
<Property Id="TESTPROPERTY2" Value="World" />
<CustomAction Id="ShowProperty" Script="vbscript" Execute="deferred">
<![CDATA[
Dim properties
properties = Split(Session.Property("CustomActionData"), ";", -1, 1)
MsgBox properties(0) & ", " & properties(1) & "!"
]]>
</CustomAction>
<CustomAction Id="SetPropertyForShowProperty"
Property="ShowProperty"
Value="[TESTPROPERTY];[TESTPROPERTY2]" />
<InstallExecuteSequence>
<Custom Action="SetPropertyForShowProperty" Before="InstallInitialize">Not Installed</Custom>
<Custom Action="ShowProperty" Before="InstallFinalize">Not Installed</Custom>
</InstallExecuteSequence>
- WiX Custom Action 的deferred !
- wix custom action
- Wix Custom Action 运行exe文件
- Wix打包系列(三)自定义Action(Custom Action)
- Wix打包系列(三)自定义Action(Custom Action)
- Wix打包系列(三)自定义Action(Custom Action)
- Wix打包系列(三)自定义Action(Custom Action)
- wix custom action 之 vbscript 简明步骤(IS2120@BG57IV3)
- InstallShield的Custom Action
- 我的图片AI中 Custom Action
- Custom Drillthrough Action
- 如何在Windows Installer的Custom Action中Sleep
- wix
- WIX
- Wix
- wix
- jQuery的deferred对象
- jquery 的deferred对象
- 构建Java本地仓库(构件库)——Nexus OSS
- angular foreach的使用
- NIO机制深入及代码示例
- POJ3281 网络流 dining
- 设计模式(20)——享元模式
- WiX Custom Action 的deferred !
- Android Application
- c++ 常见笔试题
- Python第一个让我觉得诡异的小地方
- Free game arts
- 设计模式(21)——访问者模式
- JAVA异常处理之重--项目实战经验
- java同步机制简单介绍
- 数据结构之链式表