'Remember Property'模式和RadioButtonGroup中使用的属性

时间:2016-02-01 15:09:55

标签: wix

我正在尝试在安装过程中保存注册表中的属性值,并在下次安装运行时读取它。 我按照here

所述的'记住属性'模式

它基本上按预期工作,但我不能让一个场景工作:

  • 我运行setup(属性存储在注册表中)
  • 我再次运行安装程序而不在命令行上输入属性值
  • 我希望从注册表中读取属性的值,但是它被赋予默认值。

我想,我知道问题出在哪里:我为该属性分配了“值”,而我上面提到的例子,声明了没有“值”的“记住”属性。在我的包中,我必须定义值,因为我在使用RadioButtonGroup的UI元素中使用了该属性。如果我没有声明属性的Value字段,我会收到编译错误:

 error LGHT0204 : ICE34: Property LOCATION (of RadioButtonGroup control LocationSelection.InstallationLocation) is not defined in the Property Table.

任何人都可以给我一个如何管理它的提示吗?

1 个答案:

答案 0 :(得分:2)

以下是解决方案草案:

填充属性的自定义操作

<CustomAction Id='SaveCmdLineValueLocation' Property='CMDLINE_LOCATION'
              Value='[LOCATION]' Execute='firstSequence' />
<CustomAction Id='SetFromCmdLineValueLocation' Property="EFFECTIVE_LOCATION"
              Value='[CMDLINE_LOCATION]' Execute='firstSequence' />
<CustomAction Id='SetFromRegValueLocation' Property="EFFECTIVE_LOCATION"
              Value='[REG_LOCATION]' Execute='firstSequence' />

执行从注册表或msiexec命令行分配EFFECTIVE_LOCATION的序列:

<InstallExecuteSequence>
      <Custom Action='SaveCmdLineValueLocation' Before='AppSearch'>
        LOCATION
      </Custom>      
      <Custom Action='SetFromCmdLineValueLocation' After='AppSearch'>
        CMDLINE_LOCATION
      </Custom>
      <Custom Action='SetFromRegValueLocation' After='AppSearch'>
        REG_LOCATION AND (NOT CMDLINE_LOCATION)
      </Custom>
</InstallExecuteSequence>

属性声明:

<!-- Property used on command-line. -->
<Property Id="LOCATION" Secure="yes">
</Property>

<!-- Property used finally with ReadioButtonGroup. It must have Value assigned (required when used with RadioButtonGroup -->
<Property Id="EFFECTIVE_LOCATION" Value="OFFICE" Secure="yes">
</Property>

<!-- Read previous value from registy (from recent installation) -->
<Property Id="REG_LOCATION" Secure="yes">
  <RegistrySearch Id="loc" Root="HKLM" Key="SOFTWARE\Company\Product" Type="raw" Name="LOCATION"  Win64='yes'>
  </RegistrySearch>
</Property>