Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy file from setup location to another location in wix on install

I have created an msi setup file which includes some files in a "Sample" folder which should be copied to a temp folder. Anybody suggest how to do this?

like image 606
Sukhjeevan Avatar asked Dec 06 '10 06:12

Sukhjeevan


2 Answers

Something like this:

   <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="MyVendor" Name="MyVendor">
            <Directory Id="INSTALLDIR" Name="MyDir">
                <Component Id="MyFileId" Guid="...G1...">
                    <File Id="MyFileId" Name="MyFile" Source="...blabla...\MyFile" KeyPath="yes" >
                    </File>
                </Component>


     <DirectoryRef Id="TARGETDIR">
            <Component Id="MyFileCopyId" Guid="...G2...">
                <RemoveFile Id="MyFileRemoveId" Name="MyFile" On="install" Directory="MyCopyDir" />
                <CopyFile Id="MyFileCopyId" FileId="MyFileId" DestinationDirectory="MyCopyDir" />
            </Component>


    <Feature Id="MyFeature" ... >
            <ComponentRef Id="MyFileId" />
            <ComponentRef Id="MyFileCopyId" />

The important Xml element is CopyFile. You need to create a new component that is a copy of the first one (with different ids, guids, ... of course). Both components needs to be declared in a feature.

like image 73
Simon Mourier Avatar answered Nov 12 '22 19:11

Simon Mourier


CopyFile element is your friend. You can nest it under the original File element a number of times, depending on how many times you need to copy it. Put the correct destination folder(s) and let Windows Installer do the rest.

like image 39
Yan Sklyarenko Avatar answered Nov 12 '22 18:11

Yan Sklyarenko