If you need to change/set a directory or a subdirectory dynamically "on the fly", either based upon a value from a dialog or some other means there are two things you need to do and one caveat:
1. Create a custom action that sets the directory value:
<customaction id="AssignWebDir" directory="WEBSITEDIRECTORY" value="[WEBSROOTDIR][DIRNAME]">
2. Schedule the action during the InstallExecution phase (must be after the CostFinalize step):
<custom action="AssignWebDir" after="CostFinalize"><![CDATA[NOT Installed AND (&WebServer = 3) AND NOT (!WebServer = 3)]]> </custom>
The reason why it work's is that, at the time you've scheduled the custom action the directory name, which is also a property, has been resolved. In the above example, assume that the parent directory, named WEBSROOTDIR, is the default "C:\Inetpub\wwwroot\". Under the parent directory is where you've specified WEBSITEDIRECTORY to be. Even though you may specify an initial directory name (e.g. "fiddler") on the
The full condition is if the product is not installed (i.e. it's being installed) and if the Feature (in this case the "WebServer" feature) is being installed locally and it's not already installed locally. Finally the Directory= attribute causes WiX to create a Type 35 Custom Action whereas using Property= causes WiX to create a Type 51 Custom Action.
Tip:- <![CDATA[...]]> around the conditions "preserves" the xml integrity because of the ampersand (&) character in front of the Feature name.