WiX:更改目录的路径不会改变子目录的路径?

时间:2013-09-09 19:31:25

标签: wix

我有一个WiX安装程序,其中包含此目录声明:

<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>

我有一个对话框允许更改安装文件夹位置:

<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变量保留其原始路径。见日志:

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\'.

导致尝试在不存在的文件夹下创建子文件夹。

我应该添加什么才能将安装文件夹的路径流更改为其子文件夹?

修改

填充目录。一个在一个单独的wxs文件中,由Heat收集一组文件,另一个像这样:

<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>

我最初只在我的功能中引用了组件组:

<Feature Id="Everything" Level="1" Display='expand' ConfigurableDirectory='INSTALLFOLDER'>
    <ComponentGroupRef Id="Components" />
    <ComponentGroupRef Id="Configuration" />
</Feature>

但我现在已经使用自己的ConfigurableDirectory属性创建了子功能:

<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>

我不注意任何一种方式。

1 个答案:

答案 0 :(得分:4)

您是否尝试使用自定义操作?

您可以使用以下自定义操作之一在安装期间更改属性值:

  1. 自定义操作,用于更改在CostFinalize
  2. 之前计划的目录属性值
  3. 类型35自定义操作,用于更改目录路径(应在CostFinalize之后安排)
  4. 例如:

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

    2.在InstallExecution阶段安排行动(必须在CostFinalize步骤之后):

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