WiX Bundle bal:condition - util:RegistrySearch variable always false

后端 未结 1 1559
生来不讨喜
生来不讨喜 2020-12-16 17:16

I want my install to fail if a third-party software element is not installed. I added a Fragment with a util:RegistrySearch and a bal:Conditi

相关标签:
1条回答
  • 2020-12-16 17:25

    The root issue is that the RegistrySearch is in a separate Fragment that never gets referenced. Because nothing in the Fragment gets referenced the linker "optimizes away" the contents of the Fragment and the search is not included in your Bundle.

    Aside: you could argue that the fact that there is a reference to the variable mentioned in the search in the Condition that the linker should be able to figure out that the search is necessary. However, that doesn't work out in all cases.

    Fortunately, the solution is quite simple! You even have to choose from one of two:

    1. Move the RegistrySearch element to the Bundle element.
    2. Add a RegistrySearchRef element in the Bundle element to reference the RegistrySearch in the Fragment. You will also need to give the RegistrySearch and Id attribute.

    Personally, I like option two and I would probably even move the Condition into the Fragment as well to group all that stuff together. Something akin to:

    <Bundle ...>
       <util:RegistrySearchRef Id='SearchForThirdParty' />
    
       ...
    
    </Bundle>
    
    <Fragment>
       <util:RegistrySearch
              Id='SearchForThirdParty' 
              Variable="ThirdPartyCOMLibraryInstalled" 
              Result="exists"
              Root="HKLM"
              Key="SOFTWARE\Classes\ThirdPartyId.Server\CLSID"/>
    
        <bal:Condition Message="ThirdParty Application COM Library Required. Please (re)install ThirdParty Application and ensure 'Windows API' and '.Net Components' are installed.">ThirdPartyCOMLibraryInstalled</bal:Condition>
      </Fragment>
    </Wix>
    

    That should do it.

    0 讨论(0)
提交回复
热议问题