是否可能,如果可以,如何在WiX安装项目中从多个属性创建单个值?
具体来说,我有一些像这样的对话......
<Dialog Id="ConnectionStringDlg" Width="370"
Height="270" Title="Database Settings - [ProductName]" NoMinimize="yes">
<!-- Connection String -->
<Control Id="TitleLabel" Type="Text" X="45" Y="60" Width="100" Height="15" TabSkip="yes" Text="Connection String" />
<Control Id="DSLabel" Type="Text" X="45" Y="77"
Width="100" Height="15" TabSkip="no" Text="&Data Source: " />
<Control Id="DSEdit" Type="Edit" X="45" Y="92"
Width="220" Height="18" Property="CONNECTION_STRING_DS" Text="{200}" />
<Control Id="ICLabel" Type="Text" X="45" Y="107"
Width="100" Height="15" TabSkip="no" Text="&Initial Catalog: " />
<Control Id="ICEdit" Type="Edit" X="45" Y="122"
Width="220" Height="18" Property="CONNECTION_STRING_IC" Text="{200}" />
<Control Id="UIDLabel" Type="Text" X="45" Y="137"
Width="100" Height="15" TabSkip="no" Text="&User ID: " />
<Control Id="UIDEdit" Type="Edit" X="45" Y="152"
Width="220" Height="18" Property="CONNECTION_STRING_UI" Text="{200}" />
<Control Id="PassLabel" Type="Text" X="45" Y="167"
Width="100" Height="15" TabSkip="no" Text="&Password: " />
<Control Id="PassEdit" Type="Edit" X="45" Y="182" Password="yes"
Width="220" Height="18" Property="CONNECTION_STRING_PASS" Text="{200}" />
<!-- Back button -->
<!--<Control Id="Back" Type="PushButton" X="180" Y="243"
Width="56" Height="17" Text="&Back">
<Publish Event="NewDialog" Value="PoolSettingsDlg">1</Publish>
</Control>-->
<Control Id="Next" Type="PushButton" X="236" Y="243"
Width="56" Height="17" Default="yes" Text="&Next">
<Publish Event="NewDialog" Value="CustomizeDlg">
<!--if settings are correct, allow next dialog-->
<![CDATA[CONNECTION_STRING <> ""]]>
</Publish>
</Control>
<Control Id="Cancel" Type="PushButton" X="304" Y="243"
Width="56" Height="17" Cancel="yes" Text="Cancel">
<Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
</Control>
<Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0"
Width="370" Height="44" TabSkip="no" Text="WixUI_Bmp_Banner" />
<Control Id="Description" Type="Text" X="25" Y="23"
Width="280" Height="15" Transparent="yes" NoPrefix="yes">
<Text>Please enter database configuration</Text>
</Control>
<Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
<Control Id="Title" Type="Text" X="15" Y="6"
Width="200" Height="15" Transparent="yes" NoPrefix="yes">
<Text>{\WixUI_Font_Title}Database Settings</Text>
</Control>
<Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
</Dialog>
我用它以用户友好的方式从最终用户获取连接字符串信息。然后,我在安装时使用...
在web.config文件中设置此值<Component Id="cmp623DDF82F0F7645ADAAF0E7573713162" Guid="{8CFDC325-BC71-4A2F-AB22-68B0AE56C98B}">
<File Id="fil5B0B918C0DAF7B2ECC5EB9C7CC0B9FFC" KeyPath="yes" Source="Publish\Web.config" />
<util:XmlFile Id="ModifyConnectionString"
Action="setValue"
Permanent="yes"
ElementPath="//configuration/connectionStrings/add[\[]@name='RawConnection'[\]]"
Name="connectionString"
File="[#fil5B0B918C0DAF7B2ECC5EB9C7CC0B9FFC]"
Value="[CONNECTION_STRING]"
SelectionLanguage="XSLPattern"
Sequence="1"/>
</Component>
我的问题是,如何通过在对话框中设置多个属性组合来设置连接字符串值?
答案 0 :(得分:0)
您可以使用MSI Community extensions,因为它为您提供了一个很好的界面,并为您格式化字符串。
但是,如果您想手动构建它,可以在Value
属性中进行字符串构建:
<util:XmlFile Id="ModifyConnectionString"
Action="setValue"
Permanent="yes"
ElementPath="//configuration/connectionStrings/add[\[]@name='RawConnection'[\]]"
Name="connectionString"
File="[#fil5B0B918C0DAF7B2ECC5EB9C7CC0B9FFC]"
Value='Server=[CONNECTION_STRING_DS];Database=[CONNECTION_STRING_IC];User Id=[CONNECTION_STRING_UI];Password=[CONNECTION_STRING_PASS];'
SelectionLanguage="XSLPattern"
Sequence="1"/>
或者,如果您需要设置单个属性以在多个位置使用,您可以使用CustomAction或SetProperty元素(它们都执行相同的操作):
<CustomAction Id='SetConnectionString'
Property='CONNECTION_STRING'
Before='ExecXmlFile'
Value='Server=[CONNECTION_STRING_DS];Database=[CONNECTION_STRING_IC];User Id=[CONNECTION_STRING_UI];Password=[CONNECTION_STRING_PASS];' />
<SetProperty Id='CONNECTION_STRING'
Before='ExecXmlFile'
Value='Server=[CONNECTION_STRING_DS];Database=[CONNECTION_STRING_IC];User Id=[CONNECTION_STRING_UI];Password=[CONNECTION_STRING_PASS];' />