[wix-users] Set Directory in WiX

Ven H venh.123 at gmail.com
Sun Jan 28 23:59:47 PST 2018


I am trying to create a folder at a location different from the application
installation location which happens to be C:\Program Files(x86). I am using
the following fragment

 <Fragment>
    <DirectoryRef Id="TARGETDIR">
      <Directory Id="PhotosDir" Name="Photos" />
    </DirectoryRef>
    <!--<SetDirectory Id="PhotosDir" Value="[TARGETDIR]Photos"
Sequence="execute"></SetDirectory>-->
  </Fragment>

  I tried with a SetDirectory element as shown above and also with a
CustomAction as shown below. (If I use both, I get an error saying Id is
duplicated. Hence I commented it.)

  <CustomAction Id="SetPhotosDir" Directory="PhotosDir"
Value="[TARGETDIR]Photos"></CustomAction>
    <InstallExecuteSequence>
      <Custom Action="SetPhotosDir" Before="CreateFolders"/>
    </InstallExecuteSequence>
  I have a component also defined for this directory element as below.

  <Component Id="cmpPhotosDir"
Guid="{8F757344-CA0A-42BC-B292-A51CE86B19E2}" KeyPath="yes"
Directory="PhotosDir"><CreateFolder/></Component>

  But the directory called Photos is always getting created in D drive,
even though it is nested inside of TARGETDIR. I actually want to control
the location where this directory gets created, probably through UI. I
googled for SetDirectory element example, but couldn't find a proper
working sample. All I get to see is that I have to use a custom action type
35 or 51. But it is not clear what code should go inside of these custom
actions. Also, I am not sure, if these custom actions are required in
addition to the SetDirectory element or not. Can anyone please help me
achieve this, with some working sample?

Regards,
Venkatesh


More information about the wix-users mailing list