WiX: Changing the path of a directory does not cha

2019-02-18 08:15发布

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

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?

EDIT

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>

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.

标签: wix
1条回答
男人必须洒脱
2楼-- · 2019-02-18 09:01

Did you try using custom actions?

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>
查看更多
登录 后发表回答