'Remember Property' pattern and the proper

2019-07-10 14:15发布

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:

  • I run setup (property gets stored in the registry)
  • I run setup again without entering property value on command line
  • I expect value of the property to be read from registry, but it is assigned default 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?

标签: wix
1条回答
迷人小祖宗
2楼-- · 2019-07-10 14:43

Here is solution draft:

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' />

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>

Properties declaration:

<!-- 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>
查看更多
登录 后发表回答