The following explanation might not be valid 100%, it's the way that I explain it to myself ;-).
WiX takes the value of a property and uses it to resolve the path. In the first case it finds the property in the directory structure, so the path can be resolved. In the second example SERVERPATH
is just the string SERVERPATH
, so it can't find anything. You have to either set it using a registry search or to a concrete path or by a custom action.
What worked great for me in the UI and custom dialogs (I had a similar requirement with the installation folder and an additional path) was the answer to a similar question.
Here is an example for setting it via a custom action (INSTALLLOCATION
in my case was read from the registry, but it can be any path; INSTALLDIR
is defined by the directory structure in the WiX source file):
<CustomAction Id="SetINSTALLDIR" Property="INSTALLDIR" Value="[INSTALLLOCATION]" Execute="firstSequence" />
<InstallExecuteSequence>
<Custom Action="SetINSTALLDIR" After="AppSearch">INSTALLLOCATION</Custom>
</InstallExecuteSequence>
<InstallUISequence>
<Custom Action="SetINSTALLDIR" After="AppSearch">INSTALLLOCATION</Custom>
</InstallUISequence>
Using the method described in the answer above I have the following in my WiX source file:
<Directory Id="LUCENEFOLDER" SourceName="LuceneIndex" />
The path is then set in the UI on a custom dialog by the following snippet:
<Control Id="LuceneFolderLabel" Type="Text" X="5" Y="155" Width="200" Height="10" Text="Folder containing Multiindex.config of Lucene:" TabSkip="yes" />
<Control Type="PathEdit" Id="LuceneFolder" Width="200" Height="17" X="5" Y="165" Property="LUCENEFOLDER"/>
<Control Id="LuceneFolderBrwsButton" Type="PushButton" Width="56" Height="17" X="210" Y="164" Text="Change..." >
<Publish Property="_BrowseProperty" Value="LUCENEFOLDER" Order="1">1</Publish>
<Publish Event="SpawnDialog" Value="BrowseDlg" Order="2">1</Publish>
</Control>