I'm writing a Wix installer and one of the requirements is that the user can specify a target directory. Now, I'm very unfamiliar with Wix and so am trying to get my head around how it works. Ordinarily, a user specifying an installation directory seems fairly simple, so this is what I've done:
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="PlatformProgramFilesFolder">
<Directory Id="foo" Name ="foo">
<Directory Id="INSTALLFOLDER" Name="bar" />
</Directory>
</Directory>
</Directory>
</Fragment>
So, if the user on the command line specifies a INSTALLFOLDER it will use that rather than the default install path. However, they specifically want to use the name TARGETDIR as the variable for specifying the target install directory as below:
msiexec /i foobar.msi TARGETDIR=C:\foo\bar\
Now TARGETDIR is predefined, so you can't just use it as a replacement for INSTALLFOLDER. So is there a way that I can make this work or am I just missing something very stupidly simple?