WiX:将环境变量读入属性并在文本字段中创建/修改
更新(2012-02-14):我发现在 CustomActions 中的 Install* 序列之前不可能读取环境变量。这意味着您无法读取变量并将其显示在 UI 中,除非您编写一个返回变量内容的 exe/dll...:(
我创建了两个属性来读取两个用户定义的环境变量 %MY_ENV_VAR1% 和 %MY_ENV_VAR2%定义如下:
<Property Id="ENV_MYENVVAR1" Value="0"/>
<Property Id="ENV_MYENVVAR2" Value="0"/>
之后,我在 WelcomeDlg 之后创建了两个在 UI 序列中执行的自定义操作:
<CustomAction Id="GET_MYENVVAR1" Impersonate="yes" Return="check" Execute="immediate" Property="ENV_MYENVVAR1" Value="[%MY_ENV_VAR1]"/>
<CustomAction Id="GET_MYENVVAR2" Impersonate="yes" Return="check" Execute="immediate" Property="ENV_MYENVVAR2" Value="[%MY_ENV_VAR2]"/>
<InstallUISequence>
<Custom Action="GET_MYENVVAR1" After="WelcomeDlg">1</Custom>
<Custom Action="GET_MYENVVAR2" After="GET_MYENVVAR1">1</Custom>
</InstallUISequence>
我面临的问题是,在定义的自定义操作中不会读取环境变量。相应文本字段中的“0”。这是我使用的两个控件的代码:
<Control Id="Control_EnvVar1" Property="ENV_MYENVVAR1" Type="Edit" X="35" Y="191" Width="240" Height="17"/>
<Control Id="Control_EnvVar2" Property="ENV_MYENVVAR2" Type="Edit" X="35" Y="106" Width="240" Height="17"/>
我使用 WiX 3.5.2519.0 和 MSI 2.0 作为安装程序的基础。 SP1、.NET Frameworks 版本从 2.0 到 4.0 也已安装,Windows Installer 版本是 5.0,
非常感谢 -moik!
UPDATE (2012-02-14): I found out that it's not possible to read environment variables before Install* sequences within CustomActions. This means you cannot read a variable and display it in the UI except you program a exe / dll which returns the variable content... :(
I have created two properties to read the two user defined environment variables %MY_ENV_VAR1% and %MY_ENV_VAR2%. The definition goes like this:
<Property Id="ENV_MYENVVAR1" Value="0"/>
<Property Id="ENV_MYENVVAR2" Value="0"/>
Afterwards I created two custom actions being executed in the UI sequence after the WelcomeDlg:
<CustomAction Id="GET_MYENVVAR1" Impersonate="yes" Return="check" Execute="immediate" Property="ENV_MYENVVAR1" Value="[%MY_ENV_VAR1]"/>
<CustomAction Id="GET_MYENVVAR2" Impersonate="yes" Return="check" Execute="immediate" Property="ENV_MYENVVAR2" Value="[%MY_ENV_VAR2]"/>
<InstallUISequence>
<Custom Action="GET_MYENVVAR1" After="WelcomeDlg">1</Custom>
<Custom Action="GET_MYENVVAR2" After="GET_MYENVVAR1">1</Custom>
</InstallUISequence>
The problem I face is, that the environment variables are not read within the defined custom actions. My UI always displays "0" in the respective text fields. Here is the code for the two controls I use:
<Control Id="Control_EnvVar1" Property="ENV_MYENVVAR1" Type="Edit" X="35" Y="191" Width="240" Height="17"/>
<Control Id="Control_EnvVar2" Property="ENV_MYENVVAR2" Type="Edit" X="35" Y="106" Width="240" Height="17"/>
I am using WiX 3.5.2519.0 and MSI 2.0 as basis for my setup program. The installer is running under Win 7 (x64) Professional incl. SP1, .NET Frameworks version from 2.0 to 4.0 are installed as well and the Windows Installer version is 5.0.
Any help would be really appreciated. Thanks! -moik
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论