Search code examples
c#visual-studio-2012wixcodeplex

How to validate a path stored in a property in Windows installer XML (WIX)


Is there a way to validate an installation path for a custom property defined by the user ? In WIXUI_Advanced user interface, following statement exists to validate the install path for WIXUI_INSTALLDIR property.

<Publish Dialog="Dialog_Name" Control="InstallScopeNext" Event="SpawnDialog" Value="InvalidDirDlg" Order="9"><![CDATA[NOT WIXUI_DONTVALIDATEPATH AND WIXUI_INSTALLDIR_VALID<>"1"]]></Publish>

Is there a way to validate other user defined properties that we use to store installation paths as well ? as an example I want to validate my own defined property as following.

  <Publish Dialog="Dialog_Name" Control="InstallScopeNext" Event="SpawnDialog" Value="InvalidDirDlg" Order="9"><![CDATA[MYOWN_INSTALLDIRECTORY_VALID<>"1"]]></Publish>

Code examples will be appreciated.


Solution

  • I figured it out myself. WIXUI_INSTALLDIR_VALID can only be used to validate a path which is stored in side WIXUI_INSTALLDIR property only. So at the time we define a install path, best to save the installation path in WIXUI_INSTALLDIR property and our own defined property.

     <Property Id="INSTALLDIR" Value="INSTALLFOLDER" />
     <Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
    

    Since validating installation path can only be validated for WIXUI_INSTALLDIR property, fields will not cause any harm storing in two properties.