0

これが私のセットアップです:

そこで、ブートストラッパーのインストール プロジェクトを作成しています。うまくいきましたが、もっとクリーンで簡単な方法があると思います。

基本的には、製品をインストールするときに使用する環境をユーザーに選択してもらう必要があります。これを行うには、WiX Extended Bootstrapper Application 拡張機能を使用して、最初のインストール画面にいくつかのラジオ ボタンを配置できるようにします。 すべての設定は問題ありませんでしたが、どのラジオ ボタンが選択されているかを簡単に

判断する 方法がわからないことに気付きました。そのため、回避策として、バンドルに MSI を 3 回リストし、それぞれにインストール条件を設定しました。 1 つのプロパティだけでどのラジオ ボタンが選択されているかを判断する方法はありますか?

(たとえば、InstallFolder以下のコードに示すように、プロパティを MSIに渡す場合。)現在これを行う方法がない場合、MSI を 3 回追加せずにこれを行う方法はありますか?バンドル?

これが私のコードです(基本的に同じMsiPackage3回をリストする方法に注意してください):

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
     xmlns:bal="http://schemas.microsoft.com/wix/BalExtension"
     xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
  <?include Properties.wxi ?>

  <Bundle Name="!(loc.Product.Name)" Version="$(var.Version)" Manufacturer="!(loc.Product.Manufacturer)" UpgradeCode="$(var.UpgradeCode)" Condition="VersionNT >= v5.1">
    <BootstrapperApplicationRef Id="WixExtendedBootstrapperApplication.Hyperlink2License">
      <bal:WixExtendedBootstrapperApplication SuppressRepair="yes" LicenseUrl="" ThemeFile="$(var.Bundle.ExtTheme.RadioBtns.Path)" LocalizationFile="$(var.Bundle.ExtTheme.RadioBtns.l10n.Path)" />
    </BootstrapperApplicationRef>

    <WixVariable Id="WixMbaPrereqPackageId" Value="Netfx4Full" />

    <Variable Name="InstallFolder" Type="string" Value="$(var.InstallFolder.Value)" />

    <Variable Name="RadioButton1" Type="numeric" Value="0" />
    <Variable Name="RadioButton2" Type="numeric" Value="0" />
    <Variable Name="RadioButton3" Type="numeric" Value="1" />

    <Chain>
      <!-- Other Package References Here -->

      <MsiPackage Id="DBConnections_Dev"
                  SourceFile="$(var.MSI.Path)"
                  Visible="no"
                  Vital="yes"
                  InstallCondition="RadioButton1 = 1">
        <MsiProperty Name="INSTALLFOLDER" Value="[InstallFolder]" />
        <MsiProperty Name="SELECTED_ENV" Value="1" />
      </MsiPackage>
      <MsiPackage Id="DBConnections_Stage"
                  SourceFile="$(var.MSI.Path)"
                  Visible="no"
                  Vital="yes"
                  InstallCondition="RadioButton2 = 1">
        <MsiProperty Name="INSTALLFOLDER" Value="[InstallFolder]" />
        <MsiProperty Name="SELECTED_ENV" Value="2" />
      </MsiPackage>
      <MsiPackage Id="DBConnections_Prod"
                  SourceFile="$(var.MSI.Path)"
                  Visible="no"
                  Vital="yes"
                  InstallCondition="RadioButton3 = 1">
        <MsiProperty Name="INSTALLFOLDER" Value="[InstallFolder]" />
        <MsiProperty Name="SELECTED_ENV" Value="3" />
      </MsiPackage>
    </Chain>
  </Bundle>
</Wix>
4

1 に答える 1

1

プロジェクトの CodePlex サイトでもこの質問をしたところ、開発者は次のように回答しました (完全なディスカッションへのリンクは次のとおりです: http://wixextba.codeplex.com/discussions/432341 ):

This can now be done using the custom actions feature.

彼の反応をテストしたところ、正しいことがわかりました。この機能は、バージョン3.7.4791.32058 以降で利用できます。ソースコードには、これがどのように行われるかを示す例も含まれています。関連するコードを以下に掲載しました:

カスタム アクションの C++ コードで必要:

STDMETHODIMP OnPlanCustomAction()
{
  ...
  if (SUCCEEDED(BalGetNumericVariable(L"RadioButton1", &llValue)) && llValue)
  {
    m_pEngine->SetVariableNumeric(L"RadioButton", 1);
    BalExitOnFailure(hr, "Failed to set variable.");
  }
  else if (SUCCEEDED(BalGetNumericVariable(L"RadioButton2", &llValue)) && llValue)
  {
    m_pEngine->SetVariableNumeric(L"RadioButton", 2);
    BalExitOnFailure(hr, "Failed to set variable.");
  }
  else if (SUCCEEDED(BalGetNumericVariable(L"RadioButton3", &llValue)) && llValue)
  {
    m_pEngine->SetVariableNumeric(L"RadioButton", 3);
    BalExitOnFailure(hr, "Failed to set variable.");
  }
  else if (SUCCEEDED(BalGetNumericVariable(L"RadioButton4", &llValue)) && llValue)
  {
    m_pEngine->SetVariableNumeric(L"RadioButton", 4);
    BalExitOnFailure(hr, "Failed to set variable.");
  }
  else
  {
    m_pEngine->SetVariableNumeric(L"RadioButton", 0);
    BalExitOnFailure(hr, "Failed to set variable.");
  }
  ...


WiX XML で必要 (ダウンロードされた DLL に付属の例から):

<Variable Name="RadioButton1" Type="numeric" Value="0" />
<Variable Name="RadioButton2" Type="numeric" Value="1" />
<Variable Name="RadioButton3" Type="numeric" Value="0" />
<Variable Name="RadioButton4" Type="numeric" Value="0" />

<Chain DisableSystemRestore="yes">
  <PackageGroupRef Id="NetFx40Redist" />
  <MsiPackage
    Id="Setup"
    Compressed="yes"
    SourceFile="Setup.msi"
    Vital="yes">
    <MsiProperty Name="APPLICATIONFOLDER" Value="[InstallFolder]" />
    <MsiProperty Name="RadioButton" Value="[RadioButton]" />
  </MsiPackage>
</Chain>

これらのコード サンプルの元となった元の例については、テキスト内のリンクを確認してください。これが将来他の人に役立つことを願っています。

于 2013-02-19T18:38:44.640 に答える