如何确保在使用WiX显示UI后运行FindRelatedProducts?

时间:2014-04-03 11:54:12

标签: wix windows-installer

我有一个MSI安装程序,我在安装程序UI中指定了每台机器的安装。每台机器也安装了以前的版本。

但是,FindRelatedProducts报告当前安装是按用户进行的。

MSI (c) (A4:F0) [13:33:20:490]: FindRelatedProducts: **current install is per-user**. Related install for product '<<my guid>>' is per-machine. Skipping...

从日志中我可以看到只有在FindRelatedProducts运行后才会创建ALLUSERS属性(注意时间戳):

MSI (c) (A4:A8) [13:33:25:032]: PROPERTY CHANGE: Adding ALLUSERS property. Its value is '2'.

根据用户选择的内容,属性ALLUSERS为Published

      <Publish Property="ALLUSERS" Value="2"><![CDATA[FolderForm_AllUsers="ALL" AND VersionNT>=400 AND Privileged=1 AND FolderForm_AllUsersVisible=1]]></Publish>
      <Publish Property="ALLUSERS" Value="{}"><![CDATA[FolderForm_AllUsers="ME" AND VersionNT>=400 AND Privileged=1 AND FolderForm_AllUsersVisible=1]]></Publish>


    <Control Id="AllUsersRadioGroup" Type="RadioButtonGroup" X="20" Y="175" Width="342" Height="42" Property="FolderForm_AllUsers" Text ="empty">      
      <RadioButtonGroup Property="FolderForm_AllUsers">
        <RadioButton Value="ALL" X="0" Y="0" Width="342" Height="17" Text="$(loc.InstallForAll)" />
        <RadioButton Value="ME" X="0" Y="18" Width="342" Height="17" Text="$(loc.InstallForMe)" />
      </RadioButtonGroup>

      <Condition Action="show"><![CDATA[VersionNT>=400 AND Privileged=1 AND FolderForm_AllUsersVisible=1]]></Condition>
      <Condition Action="hide"><![CDATA[NOT (VersionNT>=400 AND Privileged=1 AND FolderForm_AllUsersVisible=1)]]></Condition>
    </Control>

因此,新版本与现有版本一起安装(添加/删除程序中存在两个条目)。

<InstallUISequence>
  <Custom Action="VSDCA_FolderForm_AllUsers" After="IsolateComponents"><![CDATA[Installed="" AND NOT RESUME AND ALLUSERS=1]]></Custom>
  <Custom Action="PreventDowngrading" After="FindRelatedProducts">NEWPRODUCTFOUND</Custom>
</InstallUISequence>


<InstallExecuteSequence>
  <!-- Only schedule this custom action for the 32-bit MSI.  -->
  <?if $(var.DependenciesPlatform)=x86 ?>
  <Custom Action="CA_Err32BitMsiOn64BitOS" After="LaunchConditions">
    <![CDATA[MsiAMD64 OR Intel64]]>
  </Custom>
  <?endif ?>

  <!-- Prevent downgrading -->
  <Custom Action="PreventDowngrading" After="FindRelatedProducts">NEWPRODUCTFOUND</Custom>

  <RemoveExistingProducts Before="InstallInitialize" />

  <Custom Action="LaunchApp" After="InstallFinalize" />

  <InstallInitialize></InstallInitialize>
  <RemoveShortcuts></RemoveShortcuts>
  <InstallFiles></InstallFiles>
  <CreateShortcuts></CreateShortcuts>
  <InstallFinalize></InstallFinalize>

  <ScheduleReboot After="InstallFinalize"/>
</InstallExecuteSequence>

只有在每台计算机上安装了两个版本的应用程序时才会出现这种情况,因为FindRelatedProducts显然假定每个用户安装(因为它在用户能够选择其中一个单选按钮之前运行,因此在那里在运行时没有设置ALLUSERS个问题。

如何确保FindRelatedProducts仅在用户指定的用户界面发布ALLUSERS后执行?

1 个答案:

答案 0 :(得分:6)

我发现在用户做出选择后我需要添加以下内容以确保在用户界面中运行FindRelatedProducts

<Publish Event="DoAction" Value="FindRelatedProducts">1</Publish>

来自https://www.mail-archive.com/wix-users@lists.sourceforge.net/msg22960.html

我发现使用suppress属性并不是绝对必要的 - 它似乎也没有明确地压制InstallUISequence中的操作。