SetDirectory with Directory Properties

我只是一个虾纸丫 提交于 2019-12-24 04:01:37

问题


I'm trying to build a multi-instance installer that creates a directory with an appropriate name underneath the INSTALLDIR directory:

<Directory Id="INSTALLDIR" Name="My Product">
    <Directory Id="SERVERDIR" Name="Server" />
</Directory>
<SetDirectory Id="SERVERDIR" Value="[INSTALLDIR]Server ([INSTANCEID])">NOT (INSTANCEID="DEFAULT")</SetDirectory>

I'd hoped at least the INSTALLDIR property would have been passed in at the start of the InstallExecute sequence even if most other directories hadn't been resolved from it yet by CostFinalize. Is there any way to find the user specified installation directory before CostFinalize so I can correctly set the SERVERDIR path?


Update 1: I'm guessing in most cases INSTALLDIR itself gets resolved by CostFinalize unless it's set on the command line (hence why it's blank to me). I could have my own property that defaults to where I expect INSTALLDIR to be unless it's been set by the user. Need to figure out how the UI passes it in - hoping it just passes INSTALLDIR normally.


Update 2: The UI passes across INSTALLDIR. But it also passes across all other resolved directories including the directories beneath SERVERDIR. I need to run SetDirectory action in both sequences and come up with a default INSTALLDIR property myself. I should also buy myself a rubber duck.


回答1:


SetDirectory can use properties in formatted strings, but you need to be careful as to when such properties are set. In a normal UI install:

  • InstallUISequence runs
    • CostFinalize resolves and sets the directory properties
    • Dialogs are shown (INSTALLDIR has already been set by CostFinalize)
  • InstallExecute runs
    • Install directory properties are pushed into the sequence

The SetDirectory element runs before CostFinalize, and paths it uses must be full paths. To base the SERVERDIR property off the INSTALLDIR property as above make sure a default INSTALLDIR has been set that represents how the resolve would normally occur:

<SetDirectory Action="SetInstallDir" Id="INSTALLDIR" Value="[$(var.Variables_ProgramFilesFolderId)]$(var.Variables_ManufacturerDir)\$(var.Variables_ProductNameShort)\">INSTALLDIR=""</SetDirectory>
<SetDirectory Action="SetServerInstallDir" Id="SERVERINSTALLDIR" Value="[INSTALLDIR]Server ([INSTANCEID])\">NOT (INSTANCEID="DEFAULT")</SetDirectory>


来源:https://stackoverflow.com/questions/19497584/setdirectory-with-directory-properties

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