WiX: CopyFile attributes

wix

On install I want to optionally copy some .ini files from SOURCEDIR to TARGETDIR which means from the directory the .msi file is located to the destination folder the app is setup to.

I did <CopyFile Id="CopyIniFile" DestinationProperty="INSTALLDIR" SourceProperty="SOURCEDIR" SourceName="Dreem15.ini" Delete="no" /> but it seems it's not doing anything. The log file is not helping much.

I've been successful in doing a much more elaborate scenario with CopyFile and I'm baffeled by this simple one.

Edit: I have these rows in MoveFile table:

|FileKey     |Component     |SourceName          |SourceFolder|DestFolder|Options
|CopyIniFile |CoAppLicAndIni|Dreem15.ini         |SOURCEDIR   |INSTALLDIR|0
|MoveDataFile|CoAppLicAndIni|Dreem10_Personal.mdf|DB_DIR10    |INSTALLDIR|0

and the second one is working. DB_DIR10 is searched in registry like this

<Property Id="DB_DIR10">
    <RegistrySearch Id='DbDirSearch10' Type='raw' Root='HKLM' Key='Software\$(var.CompanyName)\$(var.MsdeInstance)' Name='Dreem10_Personal' />
</Property>

Best Answer

According to the windows installer documentation for the sourcedir property, it points to "the root directory that contains the source cabinet file or the source file tree of the installation package".

So either you were not aware that SourceDir is a predefined windows installer property, or you are trying to copy an unpackaged file from the installation medium that contains the msi. In the latter case it would probably make more sense to install the file like a normal component so that it will be properly uninstalled.

Edit: I've tested the "copy from install medium" scenario and it worked for me. Also, I've installed with

misexec /lvx* install.log /i mymsi.msi

and the log did show the file being copied. What does the log say in your case?

Edit2: While CopyFile worked for me, a better solution is to add an uncompressed medium to your wxs like this:

<Media Id='2'/>

And then adapt the File element for your customizable config file like this:

<File Source='path\to\default\config.ini' Compressed='no' DiskId='2' />

This will make the installer look for config.ini in the same folder as the msi, combining the advantages of customizability and a clean uninstall.

Related Topic