wixwix3.5

WiX -- Set Component Directory at Install Time?


The following doesn't compile, but how can I get the equivalent functionality of [MYDIR]?

<Component Id="MyComponent" Guid="MY_GUID" KeyPath="yes" Directory="[MYDIR]">
    <File Source="MyFile.dll" Name="MyFile.dll"/>
</Component>

(I'm trying to put the file MyFile.dll into a directory whose path is determined when the installer is actually run.)


Solution

  • The Directory attribute must correspond to a <Directory> tag somewhere in your installer. You can set that directory to the value of a property that gets set at runtime. A good example of this is using the WixUI_InstallDir to ask the user where they want to install an application.

    Here is an example of usage: https://wixtoolset.org//documentation/manual/v3/wixui/dialog_reference/wixui_installdir.html