C# 如何将复选框值传递到MSI文件WIX

C# 如何将复选框值传递到MSI文件WIX,c#,wix,windows-installer,C#,Wix,Windows Installer,我已经创建了WPF的安装文件,并得到了一个复选框,用户决定显示“桌面快捷方式”。但是我在把它发送到MSI文件时遇到了一个问题 这是创建桌面快捷方式。但我想在这里添加一个条件。如果选中WPF复选框“我想将其添加到桌面”,则不会发生任何情况 <Component Id="DesktopShortcutComponent" Guid="*"> <RegistryValue Id="RegShortcutDesktop&

我已经创建了WPF的安装文件,并得到了一个复选框,用户决定显示“桌面快捷方式”。但是我在把它发送到MSI文件时遇到了一个问题

这是创建桌面快捷方式。但我想在这里添加一个条件。如果选中WPF复选框“我想将其添加到桌面”,则不会发生任何情况

<Component Id="DesktopShortcutComponent" Guid="*">
        <RegistryValue Id="RegShortcutDesktop" Root="HKCU" Key="SOFTWARE\MyProject\1.0\settings" Name="DesktopSC" Value="1" Type="integer" KeyPath="yes" />
        <Shortcut Id="desktopSc" Target="[MYINSTALLFOLDER]\MyApplication.exe" Directory="DesktopFolder" Name="MyApplication" Icon="MyProductIcon" IconIndex="0" WorkingDirectory="MYINSTALLFOLDER" Advertise="no" />
        <RemoveFolder Id="RemoveShortcutFolder" On="uninstall" />
    </Component>

您可以像这样设置字符串或数字变量

BootstrapperApplication.Engine.StringVariables["InstallDir"] = "somePath";
BootstrapperApplication.Engine.StringVariables["Cbx"] = "True";
BootstrapperApplication.Engine.NumericVariables["Variable"] = 1;
在Bundle.wxs中

<Variable Name="InstallDir"
              bal:Overridable="yes" />
<Variable Name="Cbx"
              bal:Overridable="yes"/>


<MsiPackage SourceFile="$(var.Some.Setup.TargetDir)Some.Setup.msi"
                  Id="InstallationPackageId"
                  Visible="no">
    <MsiProperty Name="INSTALLFOLDER" Value="[InstallDir]" />
    <MsiProperty Name="CBX" Value="[Cbx]" />
</MsiPackage>

Product.wxs

<Property Id="CBX" Value="False" Secure="yes" />

<Component Id="Shortcut"
           Directory="INSTALLFOLDER"
           Guid="68D52920-E643-42F9-B1C6-8D9D1D8C8B2E">
   <RegistryValue Id="RegShortcutDesktop"
                  Root="HKCU"
                  Key="SOFTWARE\MyProject\1.0\settings"
                  Name="DesktopSC"
                  Value="1"
                  Type="integer"
                  KeyPath="yes" />
   <Shortcut Id="desktopSc"
             Target="[INSTALLFOLDER]\Podit.exe"
             Directory="INSTALLFOLDER"
             Name="Podit"
             Icon="icon.ico"
             IconIndex="0"
             WorkingDirectory="INSTALLFOLDER"
             Advertise="no" />
   <Condition><![CDATA[CBX = "True"]]></Condition>
</Component>


检查此项如何在Product.wxs中捕获此“int变量”?并检查它是1还是0我想创建桌面快捷方式取决于“BootstrapperApplication.Engine.NumericVariables[“Variable”]=1”如果它的1在桌面上创建快捷方式,如果它的0不创建快捷方式@闇Yami添加条件设置
为什么不工作?我向此发送了1,但con不起作用。我已选中,快捷方式创建良好,在
%temp%
中,您可以找到安装日志文件,并检查
CBX
的值。
<Property Id="CBX" Value="False" Secure="yes" />

<Component Id="Shortcut"
           Directory="INSTALLFOLDER"
           Guid="68D52920-E643-42F9-B1C6-8D9D1D8C8B2E">
   <RegistryValue Id="RegShortcutDesktop"
                  Root="HKCU"
                  Key="SOFTWARE\MyProject\1.0\settings"
                  Name="DesktopSC"
                  Value="1"
                  Type="integer"
                  KeyPath="yes" />
   <Shortcut Id="desktopSc"
             Target="[INSTALLFOLDER]\Podit.exe"
             Directory="INSTALLFOLDER"
             Name="Podit"
             Icon="icon.ico"
             IconIndex="0"
             WorkingDirectory="INSTALLFOLDER"
             Advertise="no" />
   <Condition><![CDATA[CBX = "True"]]></Condition>
</Component>