1
votes

I'm trying to create an installer using WiX. To includes DLLs into .msi package I tryied two different ways. One of these is:

<DirectoryRef Id="SETTINGSDIR">
  <Component Id="CMP_CopySettings" Guid="AC7D1AA1-798B-48F5-AF8D-188B1050D47C" KeyPath="yes">
    <CreateFolder />
    <File Id="DBA.bat" Source="$(var.SolutionDir)\scr\A\A.WindowsService\bin\$(var.Configuration)\Settings\A_DB clear.bat" Checksum="yes"/>
    <File Id="AConfiguration.xml" Source="$(var.SolutionDir)\scr\A\A.WindowsService\bin\$(var.Configuration)\Settings\AConfiguration.xml" Checksum="yes"/>
    <File Id="ADB.CE.DEFAULT.sdf" Source="$(var.SolutionDir)\scr\A\A.WindowsService\bin\$(var.Configuration)\Settings\ADB.CE.DEFAULT.sdf" Checksum="yes"/>
    <File Id="ADB.CE.sdf" Source="$(var.SolutionDir)\scr\A\A.WindowsService\bin\$(var.Configuration)\Settings\A.CE.sdf" Checksum="yes"/>
    <RemoveFile Id="RemoveFileSettings" Name="*" On="uninstall"/>
  </Component>
</DirectoryRef>

But as you can easily understand, it's very hard write an xml node for each DLL (6 projects with 200+ DLLs for each one).

The second one is faster, but WiX just creates a link to the folder instead of copy DLLs into msi package

<DirectoryRef Id="SETTINGSDIR">
  <Component Id="CMP_CopySettings" Guid="AC7D1AA1-798B-48F5-AF8D-188B1050D47C" KeyPath="yes">
    <CreateFolder />
    <CopyFile Id="SettingsID" SourceProperty="SETTINGSSOURCEDIRECTORY" DestinationDirectory="SETTINGSDIR" SourceName="*" />
    <RemoveFile Id="RemoveFileSettings" Name="*" On="uninstall"/>
  </Component>
</DirectoryRef>

Is there a quick solution that can I add at my second way or I have to use heat.exe tool? In this case, can you explain me how to use it? The official documentation is very poor

Thanks

1
Also FYI, you do not need <RemoveFile> or <CreateFolder/> tags in your component. Another best practice is to have a separate component for every file in your installer unless they are very tightly coupled together. Your second approach is not a good idea because it will remove everything in that directory. Even files the installer has absolutely no right to be removing (if the user put them there for whatever reason). Hopefully the heat tool is very helpful for you. I use it to harvest a 3000+ files directory into an SDK installer so it is quite helpful.Brian Sutherland

1 Answers

5
votes

What you want is an harvest tool to do this for you. Luckily it already exists: Heat

In your specific case you might want to use the command heat dir ".\My Files" -gg -g1 -directoryid "YourDirectoryId" -sfrag -template:fragment -out directory.wxs but check what is exactly your need, which harvesting you want to skip etc...

Note the -t <xsl> switch which gives you the total control on how you want to tune the final output.