Wix:将对话控制值传递给可配置的合并模块
我无法使用 Wix 工具集完成任务。特别是,我有一个场景,我有一个配置 MSM(可配置模块)的 MSI。 MSI 有一个自定义 UI 对话框,用户输入可用于配置 MSM。
当我尝试使用地址属性的硬编码值来配置 MSM 时,如下所示,它工作正常并且 MSM 配置正确。 (我相信这种配置是在构建时而不是运行时发生的 - 问题可能就在那里。)。
当我在安装时(即运行时)使用自定义对话框设置地址属性的值时,就会出现问题。可配置模块仍然使用硬编码值,而不是用户输入。问题是因为合并模块配置仅在构建时完成。有没有办法从主 MSI 的 UI 向合并模块传递值?
这是一个过于简化的版本:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="cf1d176d-2d57-435e-8e7f-abba14de821c" Language="1033">
<Media Id="1" Cabinet="SemanticEvolution.cab" EmbedCab="yes" />
<Property Id="Address" Value="http://127.0.0.1" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLLOCATION" Name="Semantic Evolution">
<Merge Id="MergeModule" Language="1033" SourceFile="Module.msm" DiskId="1">
<ConfigurationData Name="EndpointAddressConfiguration" Value="[Address]" />
</Merge>
</Directory>
</Directory>
</Directory>
<Feature Id="SemanticEvolutionFeatures" Title="Semnatic Evolution" Level="1">
<Feature Id="TestFeature" Title="TestFeature" Level="1">
<MergeRef Id="MergeModule" />
</Feature>
</Feature>
<UI Id="CustomWixUI">
<UIRef Id="WixUI_FeatureTree" />
<DialogRef Id="ConfigurationDlg" />
<Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="ConfigurationDlg">LicenseAccepted = "1"</Publish>
<Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="ConfigurationDlg">NOT Installed</Publish>
</UI>
</Product>
</Wix>
这是合并模块的片段:
<Configuration Name="EndpointAddressConfiguration" Format="Text" />
<Substitution Table="CustomAction" Row="SetEndpointAddress" Column="Target" Value="[=EndpointAddressConfiguration]" />
<CustomAction Id="SetEndpointAddress" Property="EndpointAddress" Value="[EndpointAddress]" />
<InstallExecuteSequence>
<Custom Action="SetEndpointAddress" Before="LaunchConditions">1</Custom>
</InstallExecuteSequence>
最终在合并模块中,配置的属性按如下方式使用:
<util:XmlFile Id="EndpointAddress" Action="setValue" ElementPath="/configuration/system.serviceModel/client/endpoint/@address" File="[#Se.Gui.exe.config]" Value="[EndpointAddress]/ApiDataService"/>
I'm having trouble accomplishing a task with the Wix Toolset. In particular, I have a scenario where I have an MSI that configures an MSM (Configurable Module). The MSI has a custom UI dialogue from which user input is to be used to configure the MSM.
When I try to configure the MSM using a hardcoded value for the address property as shown below it works fine and the MSM is configured correctly. (I believe this configuration happens and build-time as opposed to run-time - the issue may lay there.).
The problem occurs when I use a custom dialogue to set the value of the address property at installation time (i.e run-time). The configurable module still uses the hardcoded value, rather than the users input. Is the problem because merge module configuration is done during build-time only. Is there a way to pass a value to the merge module from the UI of the main MSI?
Here is an over simplified version:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="cf1d176d-2d57-435e-8e7f-abba14de821c" Language="1033">
<Media Id="1" Cabinet="SemanticEvolution.cab" EmbedCab="yes" />
<Property Id="Address" Value="http://127.0.0.1" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLLOCATION" Name="Semantic Evolution">
<Merge Id="MergeModule" Language="1033" SourceFile="Module.msm" DiskId="1">
<ConfigurationData Name="EndpointAddressConfiguration" Value="[Address]" />
</Merge>
</Directory>
</Directory>
</Directory>
<Feature Id="SemanticEvolutionFeatures" Title="Semnatic Evolution" Level="1">
<Feature Id="TestFeature" Title="TestFeature" Level="1">
<MergeRef Id="MergeModule" />
</Feature>
</Feature>
<UI Id="CustomWixUI">
<UIRef Id="WixUI_FeatureTree" />
<DialogRef Id="ConfigurationDlg" />
<Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="ConfigurationDlg">LicenseAccepted = "1"</Publish>
<Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="ConfigurationDlg">NOT Installed</Publish>
</UI>
</Product>
</Wix>
Here is a snipet of the merge module:
<Configuration Name="EndpointAddressConfiguration" Format="Text" />
<Substitution Table="CustomAction" Row="SetEndpointAddress" Column="Target" Value="[=EndpointAddressConfiguration]" />
<CustomAction Id="SetEndpointAddress" Property="EndpointAddress" Value="[EndpointAddress]" />
<InstallExecuteSequence>
<Custom Action="SetEndpointAddress" Before="LaunchConditions">1</Custom>
</InstallExecuteSequence>
Eventually in the merge module the configured property is used as follows:
<util:XmlFile Id="EndpointAddress" Action="setValue" ElementPath="/configuration/system.serviceModel/client/endpoint/@address" File="[#Se.Gui.exe.config]" Value="[EndpointAddress]/ApiDataService"/>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请记住,公共属性必须大写。
您可以在这里找到答案:
http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Passing-properties-to-merge-modules-td5417112.html
Remember that public properties must be in UPPERCASE.
You can find the answer here:
http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Passing-properties-to-merge-modules-td5417112.html
要从合并模块访问属性,您必须将合并模块 ID 附加到属性名称。类似于:MyProp.msm_guid
http://msdn.microsoft。 com/en-us/library/aa370051(VS.85).aspx
To access a property from a merge module you must append the merge module id to the property name. Something like: MyProp.msm_guid
http://msdn.microsoft.com/en-us/library/aa370051(VS.85).aspx