WIX: Change install directory from c# class parameter?

拟墨画扇 提交于 2019-12-13 04:29:32

问题


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.


回答1:


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>



回答2:


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,



来源:https://stackoverflow.com/questions/18716616/wix-change-install-directory-from-c-sharp-class-parameter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!