Deqing
Deqing

Reputation: 14652

WiX - How to change name of a directory after installation

Pretty simple question, suppose my app will be installed as

myApp
 +-- bin
 +-- lib

I'd like to rename "lib" to "plugins" after installation, how can i do that?

There is a MoveFiles Element that might help, but no idea how to use it.

EDIT:

The problem here is, in my case, source files could be installed into different paths, this scenario described in here.

The only way I can figure out is to create two component groups and install them conditionally. However, using heat to harvest same subdir twice will cause ID conflicting, so I'm thinking to use different paths(e.g. lib and another-lib), and then rename one of the path back after installation, so this question arised...

Upvotes: 0

Views: 1050

Answers (2)

Deqing
Deqing

Reputation: 14652

I finally wrote a C++ program to extend heat generated wxs with another directory structure. So we can decide which path to install under different situations. It worked just like changing name during installation.

Here is the wxs file patched by my program. Basically it creates another directory WEBIDR and different subdirs, then adds another component group webGroup for later reference by condition element.

You can do the same thing manually, but if there are thousands of files awaiting, and if they are frequently updating, maybe a program(or script) is a better choice.

<Fragment>
    <DirectoryRef Id="INSTALLDIR">
        <Directory Id="dirA5528701EE26FFBF346CCE20EE8ACE99" Name="bin">
            <Component Id="cmpEBA9C2A32D81BA8646BD1A64DBB39DB1" Guid="{142C531A-C71C-4890-9318-0FC42026C8FC}">
                <File Id="filDB56E052EC783676CEF361C0C5AA71F3" KeyPath="yes" Source="$(var.runDir)\bin\boost_date_time-vc100-mt-1_47.dll" />
            </Component>
        </Directory>
        <Directory Id="dir3279BEF4E08D9A00D2F205F325F00A81" Name="modules">
            <Component Id="cmpDECCAE13F8937500E4AC367A8EAC95F4" Guid="{85CC0C94-1BFB-4062-BC4E-FBF143921301}">
                <File Id="filDD3B40D68D0437B18B1108FBA49ABC1B" KeyPath="yes" Source="$(var.runDir)\modules\HelloAPI.dll" />
            </Component>
        </Directory>
    </DirectoryRef>
    <DirectoryRef Id="WEBDIR">
        <Component Id="webcmpEBA9C2A32D81BA8646BD1A64DBB39DB1" Guid="{fec110c5-a1a0-4b07-8a35-50f1af84001a}">
            <File Id="webfilDB56E052EC783676CEF361C0C5AA71F3" KeyPath="yes" Source="$(var.runDir)\bin\boost_date_time-vc100-mt-1_47.dll" />
        </Component>
        <Directory Id="webdirpluginF4E08D9A00D2F205F325F00A81" Name="plugins">
            <Component Id="webcmpDECCAE13F8937500E4AC367A8EAC95F4" Guid="{3ef79a47-7681-4991-9726-02db38c22f6d}">
                <File Id="webfilDD3B40D68D0437B18B1108FBA49ABC1B" KeyPath="yes" Source="$(var.runDir)\modules\HelloAPI.dll" />
            </Component>
        </Directory>
    </DirectoryRef>
</Fragment>
<Fragment>
    <ComponentGroup Id="runGroup">
        <ComponentRef Id="cmpEBA9C2A32D81BA8646BD1A64DBB39DB1" />
        <ComponentRef Id="cmpDECCAE13F8937500E4AC367A8EAC95F4" />
    </ComponentGroup>
    <ComponentGroup Id="webGroup">
        <ComponentRef Id="webcmpEBA9C2A32D81BA8646BD1A64DBB39DB1" />
        <ComponentRef Id="webcmpDECCAE13F8937500E4AC367A8EAC95F4" />
    </ComponentGroup>
</Fragment>

Upvotes: 0

Rob Mensching
Rob Mensching

Reputation: 36026

Don't. Install the files correctly up front. The way that the Windows Installer tracks things will fight you every step of the way. Just install the files in the correct folder from the beginning. Probably not the answer you wanted.

Upvotes: 3

Related Questions