Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the usage of TARGETDIR and INSTALLDIR in WiX?

Tags:

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?

like image 276
Adam Robinson Avatar asked Jun 12 '12 19:06

Adam Robinson


People also ask

What is Targetdir WiX?

The element with the id TARGETDIR is required by the Windows Installer and is the root of all directory structures for your installation. Every WiX project will have this directory element.

What is the usage of WiX tool?

Wix is a free, user-friendly, website building platform. Our intuitive technology and powerful built-in features give our users the freedom to design professional websites with ease that look amazing on any device. Wix is more than a website, though.

What is SourceDir in WiX?

Also according to MSDN, SourceDir is. the root directory that contains the source cabinet file or the source file tree of the installation package. So the SourceDir property points to a real directory: the one where your MSI file sits. You can see this in the installer log when installing with msiexec /lvx* installer.

What is WiX toolbox?

About the WiX toolset The core of WiX is a set of build tools that build Windows Installer packages using the same build concepts as the rest of your product: source code is compiled and then linked to create executables; in this case .exe setup bundles, . msi installation packages, . msm merge modules, and .


1 Answers

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, TARGETDIR is 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:

  1. Change all of my components and component groups to install to TARGETDIR instead of INSTALLFOLDER (the default directory that WiX put in there)
  2. Add a custom action that sets the value of the TARGETDIR property to the installation path, assuming one wasn't passed in from the command line.

To do that, I added this under the <Product> tag:

<CustomAction Id="SetTARGETDIR" Property="TARGETDIR"                Value="[ProgramFilesFolder][Manufacturer]\[ProductName]"                Execute="firstSequence" /> 

And this within the <InstallExecuteSequence> tag:

<Custom Action="SetTARGETDIR" Before="CostFinalize">TARGETDIR=""</Custom> 
like image 126
Adam Robinson Avatar answered Sep 21 '22 07:09

Adam Robinson