Emanuela
Emanuela

Reputation: 86

WIX: Change install directory from c# class parameter?

I'm creating an install wizard and i have a page where you can choose where you want to install the program. In my c# class i have InstallPath that keeps the exact directory i want to install the program.

By default it's c:\Program Files.

In my WiX setup file i have that:

<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
      <Directory Id ="Folder" Name="SomeFolder"/>
    </Directory>
</Directory>

My problem is that i don't know how to tell this Wix setup to install in InstallPath. For example if InstallPath is changed to D:\SomeFolder\Here I want to install there not in Program Files again.

Upvotes: 0

Views: 1529

Answers (2)

neilmas
neilmas

Reputation: 9

to change the path is:

<Product Id="*"> 
    <Property Id="ROOTDRIVE">
        <![CDATA[D:\]]>
    </Property>
</Product>

and for the new path D:\SomeFolder\Here, will be something like this.

<Directory Id="TARGETDIR" Name="SourceDir">
    <Directory Id="SomeFolder" Name="SomeFolder">
        <Directory Id="INSTALLFOLDER" Name="Here"/>
    </Directory>
</Directory>

greetings,

Upvotes: 0

Isaiah4110
Isaiah4110

Reputation: 10080

You can use one of these custom action to change the property value during install:

  1. a custom action which changes the directory property value scheduled before CostFinalize
  2. a type 35 custom action which changes the directory path (should be scheduled after CostFinalize)

For example:

<CustomAction Id="ChangeDir" Directory="INSTALLFOLDER" Value="[SomeValueorPropertyhere]"/>

2.Schedule the action during the InstallExecution phase (must be after the CostFinalize step):

<Custom Action="ChangeDir" After="CostFinalize"></Custom>

Upvotes: 1

Related Questions