WiX:更改目录的路径不会更改子目录的路径? [英] WiX: Changing the path of a directory does not change the path of a sub directory?
问题描述
我有一个包含此目录声明的 WiX 安装程序:
I have a WiX installer that includes this declaration of directories:
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="MyCorp" Name="MyCorp">
<Directory Id="INSTALLFOLDER" Name="FlowApp">
<Directory Id="FLOW_COMPONENTS" Name="Components"/>
<Directory Id="FLOW_CONFIGURATION" Name="Configuration"/>
</Directory>
</Directory>
</Directory>
</Directory>
我有一个对话框允许更改安装文件夹位置:
And I have a dialog to allow the install folder location to be changed:
<Fragment>
<UI>
<Dialog Id="LocationDialog" Title="FlowMaster 3000 server deployment" Width="370" Height="270" NoMinimize="no">
<Control Id="PathLabel" Type="Text" Text="Install folder" X="10" Y="30" Width="70" Height="15" TabSkip="yes"/>
<Control Id="InstallPath" Type="Edit" Property="INSTALLFOLDER" Text="{80}" X="100" Y="30" Width="260" Height="15" />
这在位置未更改时工作正常,但是当用户更改位置时,尽管正确更改了 INSTALLFOLDER 变量,但 FLOW_COMPONENTS 和 FLOW_CONFIGURATION 变量保留其原始路径.查看日志:
This works fine when the location is not changed, but when the location is changed by the user, although the INSTALLFOLDER variable is correctly changed, the FLOW_COMPONENTS and FLOW_CONFIGURATION variables retain their original paths. See log:
Action start 14:38:59: CostFinalize.
MSI (c) (B8:B0) [14:38:59:308]: Dir (target): Key: INSTALLFOLDER , Object: C:\Program Files\MyCorp\FlowApp\
MSI (c) (B8:B0) [14:38:59:308]: Dir (target): Key: FLOW_COMPONENTS , Object: C:\Program Files\MyCorp\FlowApp\Components\
MSI (c) (B8:B0) [14:38:59:308]: Dir (target): Key: FLOW_CONFIGURATION , Object: C:\Program Files\MyCorp\FlowApp\Configuration\
Action 14:39:03: LocationDialog. Dialog created
MSI (c) (B8:48) [14:39:07:302]: PROPERTY CHANGE: Modifying INSTALLFOLDER property. Its current value is 'C:\Program Files\MyCorp\FlowApp\'. Its new value: 'D:\Program Files\MyCorp\FlowApp\'.
Action start 14:39:37: ExecuteAction.
MSI (s) (64:20) [14:39:39:652]: PROPERTY CHANGE: Adding INSTALLFOLDER property. Its value is 'D:\Program Files\MyCorp\FlowApp\'.
MSI (s) (64:20) [14:39:39:652]: PROPERTY CHANGE: Adding FLOW_CONFIGURATION property. Its value is 'C:\Program Files\MyCorp\FlowApp\Configuration\'.
MSI (s) (64:20) [14:39:39:653]: PROPERTY CHANGE: Adding FLOW_COMPONENTS property. Its value is 'C:\Program Files\MyCorp\FlowApp\Components\'.
这会导致尝试在不存在的文件夹下创建子文件夹.
Which leads to an attempt to create the sub-folders under a folder that doesn't exist.
我应该添加什么才能将安装文件夹的路径更改到其子文件夹?
What should I add to have the change of the install folder's path flow to its sub-folders?
编辑
目录已填充.一个在一个单独的 wxs 文件中,其中包含一组由 Heat 收集的文件,另一个是这样的:
The directories are populated. One in a separate wxs file with a group of files harvested by Heat, and the other like this:
<ComponentGroup Id="Configuration" Directory='FLOW_CONFIGURATION'>
<Component Id="Install.json" Guid="MY_GUID" >
<File Id="Install.json" Name="Install.json" Source="$(var.SolutionDir)Configuration\Install.json" KeyPath="yes" />
</Component>
</ComponentGroup>
我最初在我的功能中简单地引用了组件组:
I initially had the component groups referenced simply in my feature:
<Feature Id="Everything" Level="1" Display='expand' ConfigurableDirectory='INSTALLFOLDER'>
<ComponentGroupRef Id="Components" />
<ComponentGroupRef Id="Configuration" />
</Feature>
但我现在用它们自己的 ConfigurableDirectory 属性使它们成为子功能:
But I've now made them sub-features with their own ConfigurableDirectory attribute:
<Feature Id="Everything" Level="1" Display='expand' ConfigurableDirectory='INSTALLFOLDER'>
<Feature Id="SubComponents" ConfigurableDirectory='FLOW_COMPONENTS'>
<ComponentGroupRef Id="Components" />
</Feature>
<Feature Id="SubConfiguration" ConfigurableDirectory='FLOW_CONFIGURATION'>
<ComponentGroupRef Id="Configuration" />
</Feature>
</Feature>
两种方式我都没有注意到任何区别.
I don't notice a difference either way.
推荐答案
您是否尝试使用自定义操作?
Did you try using custom actions?
您可以使用以下自定义操作之一在安装期间更改属性值:
You can use one of these custom action to change the property value during install:
- 更改在 CostFinalize 之前计划的目录属性值的自定义操作
- 更改目录路径的类型 35 自定义操作(应在 CostFinalize 之后安排)
例如:
<CustomAction Id="ChangeDir" Directory="INSTALLFOLDER" Value="[SomeValueorPropertyhere]"/>
2.在 InstallExecution 阶段安排动作(必须在 CostFinalize 步骤之后):
2.Schedule the action during the InstallExecution phase (must be after the CostFinalize step):
<Custom Action="ChangeDir" After="CostFinalize"></Custom>
这篇关于WiX:更改目录的路径不会更改子目录的路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!