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

后端 未结 2 1403
逝去的感伤
逝去的感伤 2020-12-11 03:47

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 th

相关标签:
2条回答
  • 2020-12-11 04:17

    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.

    0 讨论(0)
  • 2020-12-11 04:40

    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.

    0 讨论(0)
提交回复
热议问题