“记住属性"模式和 RadioButtonGroup 中使用的属性 [英] 'Remember Property' pattern and the property used in RadioButtonGroup
问题描述
我试图在安装过程中将属性值保存在注册表中,并在下次运行安装时读取它.我遵循 这里
I'm trying to save the property value in registry during setup and read it next time installation is run. I follow 'Remember property' pattern as described here
它基本上按预期工作,但我无法让一个场景工作:
It basically works as expected, but I cannot get one scenario working:
- 我运行安装程序(属性存储在注册表中)
- 我没有在命令行中输入属性值而再次运行安装程序
- 我希望从注册表中读取属性值,但它被分配了默认值.
我想,我知道问题出在哪里:我为属性分配了值",而我上面提到的示例声明了没有值"的记住"属性.在我的包中,我必须定义该值,因为我将 UI 元素中的属性与 RadioButtonGroup 结合使用.如果我不声明属性的 Value 字段,则会出现编译错误:
I think, I know where is the problem: I have "Value" assigned to the property, while the example I've mentioned above, declares "remembered" property without "Value". In my package, I have to define the value as I use the property in UI element with RadioButtonGroup. If I don't declare Value field of the property, I get compilation error:
error LGHT0204 : ICE34: Property LOCATION (of RadioButtonGroup control LocationSelection.InstallationLocation) is not defined in the Property Table.
谁能告诉我如何管理它?
Can anybody give me a hint how to manage it?
推荐答案
这里是解决方案草案:
用于填充属性的自定义操作
Custom actions to fill properties
<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 的序列:
Execute sequence that assignes EFFECTIVE_LOCATION either from registry or msiexec command line:
<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>
这篇关于“记住属性"模式和 RadioButtonGroup 中使用的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!