In legacy Visual Studio Deployment Project installers, passing a command-line parameter that specified a value for TARGETDIR allowed me to override the default installation location (most of my installations take place without user interaction, so command-line automation is used heavily). However, the impression I’m getting is that WiX (by default) uses TARGETDIR for something different. While I can (and will) update our command-line tools to change the parameter name, that still leaves all of our existing installations that would need to be touched manually (a non-trivial effort).
Is there any way to override the installation location in a WiX package by specifying TARGETDIR without breaking anything?
After doing more digging, it looks like my previous experience is a result of behavior specific to VSDPROJ’s (and possibly InstallShield), wheras WiX is conforming to the Windows Installer.
As I discovered at this link,
TARGETDIRis actually supposed to represent the root of the drive with the most free space available (assuming there’s more than one). That’s why WiX projects have directories nested under there for Program Files, etc. Visual Studio actually adds a custom action that overrides this property to the full installation path.I was able to accomplish what I wanted by doing two things:
TARGETDIRinstead ofINSTALLFOLDER(the default directory that WiX put in there)TARGETDIRproperty to the installation path, assuming one wasn’t passed in from the command line.To do that, I added this under the
<Product>tag:And this within the
<InstallExecuteSequence>tag: