Question

Our app requires a recent version of a DLL in order to function correctly. The path to the DLL is stored in the registry. How do I enforce a minimum file version as a launch condition in Windows Installer?

So far I have this:

<Property Id="FileTest">
    <RegistrySearch Id="FileSearch"
                    Key="SOFTWARE\Company\Product"
                    Name="DLLPath"
                    Root="HKLM"
                    Type="file">
        <FileSearch MinVersion="1.2.3.4" />
    </RegistrySearch>
</Property>
<Condition Message="!(loc.ErrorMessage)">Installed OR (FileTest)</Condition>

But WiX won't compile this:

MainApp.wxs(543) : error CNDL0010 : The FileSearch/@Name attribute was not found; it is required.

The problem is I don't know what to enter for the Name attribute. I don't know in advance what the DLL is named, it could be anything! (That's why the registry value is there!!)

Was it helpful?

Solution

What happens if you modify the RegistrySearch to this:

<Property Id="FileTest">
    <RegistrySearch Id="FileSearchResult"
                    Key="SOFTWARE\Company\Product"
                    Name="DLLPath"
                    Root="HKLM"
                    Type="file">
        <FileSearch LongName="[FileSearchResult]" 
                    MinVersion="1.2.3.4" />
    </RegistrySearch>
</Property>

I think having FileSearch as both the ID and an actual wix element is causing you and issue. If you change the id to something like FileSearchResult and then reference it in the Name (or safer, LongName) attribute of the FileSearch element (by enclosing it in square brackets, []), then it should work. I haven't touched wix in about 6 months, so I make no promises ;)

NOTE: The square brackets are the way the Wix UtilExtensions (as seen in this example) identify a RegistrySearch result stored in the variable attribute. It may not be so for accessing the Id holding the result in standard wix.

NOTE 2: You may actually need to use a RegistrySearchRef element as the parent to the FileSearch element instead. Take a look at this example (though it uses one result of a DirectorySearch element in another DirectorySearch). Hopefully this may give you enough to go on.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top