Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wix: How to do a DirectorySearch in a custom installation location

I would like to detect if a directory already exists in a custom installation location selected by the user in the GUI. I tried the following:

<Property Id="DIRECTORY_PATH">
  <DirectorySearch Id="DirectorySearch" Path="[INSTALLDIR]\MyDirectory" />
</Property>

But this doesn't work because the DirectorySearch is happening during AppSearch. While INSTALLDIR is set later during InstallDirDlg. Since INSTALLDIR is not set in time for AppSearch, DIRECTORY_PATH is incorrectly set to "\MyDirectory".

I tried to change when AppSearch happens with InstallUISequence and InstallExecuteSequence, but it will only let AppSearch come before CostInitialize, no later.

So how do I do a directory search at the user selected INSTALLDIR location?

like image 557
Michael Avatar asked Sep 08 '11 21:09

Michael


1 Answers

If you only have to wait for the user's choice to verify that directory, then DirectorySearch won't do the job for you. You'll have to author a "set property" custom action right after the user chooses INSTALLDIR, for instance, on a Next click of InstallDirDlg.

UPDATE. So, I mean basically the following:

  • when the user gets to the InstallDirDlg of your setup, he/she selects the directory, which is put to the INSTALLDIR property
  • the dialog InstallDirDlg should then trigger a custom action on Next button
  • this custom action should get the value of INSTALLDIR property, and do a simple file system check whether INSTALLDIR contains MyDirectory
  • if it does, the DIRECTORY_PATH property is set to the necessary value, e.g. session["DIRECTORY_PATH"] = session[INSTALLDIR] + "\MyDirectory";
  • otherwise, DIRECTORY_PATH is not set (and you can use this fact in any condition by checking NOT DIRECTORY_PATH)

Hope it makes it clearer.

like image 115
Yan Sklyarenko Avatar answered Oct 30 '22 04:10

Yan Sklyarenko