13

I'm using Wix Installer to copy a folder under program files folder. But I couldn't do it for entire folder. I can do it only by file by file basis.

I would appreciate any help on this regard

Smaug
  • 2,625
  • 5
  • 28
  • 44

1 Answers1

16
<Directory Id="CopyTestDir"...>

<Property Id="SOURCEDIRECTORY" Value="c:\doc\bin\path" />

<Component Guid="A7C42303-1D77-4C70-8D5C-0FD0F9158EB4" Id="CopyComponent">
    <CopyFile Id="SomeId" SourceProperty="SOURCEDIRECTORY"
      DestinationDirectory="CopyTestDir" SourceName="*" />
 </Component>

It doesn't handle subdirectories though. If you don't have a known directory structure for the source files, then you'll need to pursue the semi-custom action approach, writing entries into the MoveFile table for each directory.

source

Rachel Gallen
  • 27,943
  • 21
  • 72
  • 81
  • Great answer..!!! Can you just let me know instead of hard coded value(c:\doc\bin\path). How do fetch the value from part of installer? Because I'd like to distribute this to customer – Smaug Apr 17 '13 at 14:09
  • I'm not entirely sure but this question may help you http://stackoverflow.com/questions/13876128/wix-get-value-from-paths – Rachel Gallen Apr 17 '13 at 14:16
  • 3
    This answer is far from correct. Copyfile runs when the installer runs, source refers to a file location. So if you run it on your development box, where you built your .net project, it will work correctly. But the source files you are referring to are not present in your installer package (.msi or the accompanying cab files) so they will copy nothing in any other environments. As a result, it seems to work when you develop it, but in fact it doesn't. – balintn Nov 11 '18 at 17:43
  • 1
    @balintn so you have any solution, or manually typing for each file – Declan Nnadozie Jun 08 '19 at 21:23
  • Ah, that was a long time ago, but yes, I basically had to list each file to copy so that the installer knows about them (and as a result can remove them on uninstall). Wix mentions a tool (https://wixtoolset.org/documentation/manual/v3/overview/heat.html) to list files at installer creation time and thus auto-generating said file list, but I could never make it work. The – balintn Nov 06 '20 at 20:14