Copying multiple files using wildcards/recursively using Wix

callie16 picture callie16 · Oct 19, 2010 · Viewed 7.6k times · Source

I'm a total noob on Wix (and installers in general) so please forgive me.

My goal is to be able to traverse a directory, search for all, say, *.exe files and copy them to a predefined destination folder. Thing is, I don't know what these files are and their names so I can't type them out one by one in the wxs file... hence wildcards.

Now, I ended up with something like this:

...
<Directory Id='TARGETDIR' Name='SourceDir'>
      <Directory Id='ProgramFilesFolder' Name='PFiles'>
        <Directory Id='MyDir' Name='TestProj'>
          <Component Id='MyComponent' Guid='PUT_GUID_HERE'>
            <CopyFile Id="CopyFiles" DestinationProperty="DESTDIR" SourceName="*.exe" SourceProperty="SRCDIR" />
          </Component>
        </Directory>
      </Directory>
</Directory>
...

Well, this is ok if I'm reading only from SRCDIR but what if there are subfolders? How do I go down looking for files with a certain extension? Or is there another way of doing this...?

Same thing with removing those same files after the installation...

Thanks a bunch for any help you can give!

Answer

steinar picture steinar · Oct 20, 2010

A way to do this is using John Robbin's command line tool Paraffin. It goes automatically through the directories you select and creates a WiX fragment that references these files. Paraffin is great for this since it supports adding new files later without creating new GUIDs for the old files - i.e. it supports an evolving project.