准备引导程序应用程序以安装某些msi程序包。可以选择要安装的软件包。但是变量值不会根据用户选择而改变。
这就是我在Bundle.wxs
文件
<Variable Name="spectrumDb" Persisted="yes" bal:Overridable="yes" Value="1" />
<Variable Name="spectrumGateway" Persisted="yes" bal:Overridable="yes" Value="1" />
<Variable Name="spectrumServiceManager" Persisted="yes" bal:Overridable="yes" Value="1" />
<Variable Name="spectrumIISparts" Persisted="yes" bal:Overridable="yes" Value="1" />
<Variable Name="spectrumConnecter" Persisted="yes" bal:Overridable="yes" Value="1" />
我在rtf主题中有一些复选框供用户选择要安装的组件
<Page Name="Options">
<Text X="11" Y="65" Width="-11" Height="30" FontId="2" DisablePrefix="yes">Select components</Text>
<Checkbox Name="spectrumDb" X="40" Y="120" Width="200" Height="17" TabStop="yes" FontId="3" HideWhenDisabled="no" >spectrumDb</Checkbox>
<Checkbox Name="spectrumGateway" X="40" Y="140" Width="200" Height="17" TabStop="yes" FontId="3" HideWhenDisabled="no">spectrumGateway</Checkbox>
<Checkbox Name="spectrumServiceManager" X="40" Y="160" Width="200" Height="17" TabStop="yes" FontId="3" HideWhenDisabled="no" >spectrumServiceManager</Checkbox>
<Checkbox Name="spectrumIISparts" X="40" Y="180" Width="200" Height="17" TabStop="yes" FontId="3" HideWhenDisabled="no" >spectrumIISparts</Checkbox>
<Checkbox Name="spectrumConnecter" X="40" Y="200" Width="200" Height="17" TabStop="yes" FontId="3" HideWhenDisabled="no" >spectrumConnecter</Checkbox>
</Page>
无论复选框值如何,安装程序都会安装。这是我发现
的日志文件的一部分[0404:0B44][2018-05-28T08:43:07]i000: Running detect complete custom action
[0404:0B44][2018-05-28T08:43:07]i199: Detect complete, result: 0x0
[0404:178C][2018-05-28T08:43:09]i000: Setting numeric variable 'EulaAcceptCheckbox' to value 1
[0404:178C][2018-05-28T08:43:20]i000: Setting numeric variable 'spectrumDb' to value 1
[0404:178C][2018-05-28T08:43:20]i000: Setting numeric variable 'spectrumGateway' to value 1
[0404:178C][2018-05-28T08:43:20]i000: Setting numeric variable 'spectrumServiceManager' to value 1
[0404:178C][2018-05-28T08:43:20]i000: Setting numeric variable 'spectrumIISparts' to value 1
[0404:178C][2018-05-28T08:43:20]i000: Setting numeric variable 'spectrumConnecter' to value 1
我使用wix 3.11来制作这个项目。 ide是visual studio 2010。 bootstrap应用程序类型引用WixExtendedBootstrapperApplication.RtfLicense
答案 0 :(得分:0)
引导程序将在运行此函数时设置变量:
void SavePageSettings(
__in WIXSTDBA_PAGE page
)
{
THEME_PAGE* pPage = NULL;
pPage = ThemeGetPage(m_pTheme, m_rgdwPageIds[page]);
if (pPage)
{
for (DWORD i = 0; i < pPage->cControlIndices; ++i)
{
// Loop through all the checkbox controls (or buttons with BS_AUTORADIOBUTTON) with names and set a Burn variable with that name to true or false.
THEME_CONTROL* pControl = m_pTheme->rgControls + pPage->rgdwControlIndices[i];
if ((THEME_CONTROL_TYPE_CHECKBOX == pControl->type) ||
(THEME_CONTROL_TYPE_BUTTON == pControl->type && (BS_AUTORADIOBUTTON == (BS_AUTORADIOBUTTON & pControl->dwStyle)) &&
pControl->sczName && *pControl->sczName))
{
BOOL bChecked = ThemeIsControlChecked(m_pTheme, pControl->wId);
m_pEngine->SetVariableNumeric(pControl->sczName, bChecked ? 1 : 0);
}
// Loop through all the editbox controls with names and set a Burn variable with that name to the contents.
if (THEME_CONTROL_TYPE_EDITBOX == pControl->type && pControl->sczName && *pControl->sczName && WIXSTDBA_CONTROL_FOLDER_EDITBOX != pControl->wId)
{
LPWSTR sczValue = NULL;
ThemeGetTextControl(m_pTheme, pControl->wId, &sczValue);
m_pEngine->SetVariableString(pControl->sczName, sczValue);
}
}
}
}
SetVariableNumeric
函数不会记录现有变量的任何内容。
您可以通过运行引导程序,取消选中几个复选框,转到下一页,然后取消引导程序来验证您的变量是否已设置。
关闭引导程序时,它会记录所有变量及其值。在关闭引导程序后的日志中,您应该看到与取消选中的复选框对应的变量现在应该具有值0.