WiX - Set Installdirectory dynamically over CustomAction [C#]

烈酒焚心 提交于 2019-12-22 20:57:01

问题


I'm about to create an installer, now i have to set the install-directory depending on the operation-system. My directory-tree:

<Property Id="TARGETDIR" Value="C:\" />
<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="TARGETDIRECTORY" Name="MyApplication">
    <Directory Id="CONFIG" Name="Config">
      <Directory Id="FOLDER2" Name="Folder2" />
    </Directory>
  </Directory>
</Directory>

if i set the TARGETDIRECTORY in the c#-custom-action, the targetdirectory gets set correct, but the CONFIG/FOLDER2 just have the old links. How can i force them to adjust them to the new paths? because they are childs of the TARGETDIRECTORY, i guess they should do this automatically. I dont want to set it all on my own in the CustomAction, because there are even many more folders comming

here from the log file:

Property(S): FOLDER2 = C:\MyApplication\Config\Folder2\
Property(S): CONFIG = C:\MyApplication\Config\
Property(S): TARGETDIRECTORY = C:\Documents and Settings\MyApplication\
Property(S): TARGETDIR = C:\

回答1:


could solve the problem with SetProperty:

<Property Id="TARGETDIRECTORY" Value="C:\Win7\" />
<SetProperty Id="TARGETDIRECTORY" Before="CostFinalize" Value="C:\WinXP\">
  <![CDATA[VersionNT = 501]]>
</SetProperty>



回答2:


This could happen if you change the install path before CostFinalize. If this is the case you need to use a different custom action to set the path, that allows Windows Installer to be notified about the change and update the child directories.



来源:https://stackoverflow.com/questions/16103712/wix-set-installdirectory-dynamically-over-customaction-c

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