How to add a whole directory or project output to WiX package
Asked Answered
S

5

53

We decided to switch from VS integrated setup to WiX.

However, what we currently do is use projects output files as the input for the setup project. This lets us easily add Application Files to a directory (for images, samples, and other resources...) and those files are automatically added to the setup when we build.

I could not find any similar feature in WiX. WiX seems to require one Directory entry and one File entry for each and every directory and file. This would require us to change the WiX source everytime a file is added which, to my eyes, is prohibitive since we have so many of them.

Is there any integrated way of doing that with WiX or do I have to write my own task that will create a WiX source before calling candle?

Samuelson answered 5/1, 2009 at 22:6 Comment(0)
T
24

For WiX 2.0, tallow is very limited; paraffin and mallow offer additional functionality. For WiX 3.0, heat offers the same functionnality as tallow, a little bit better.

In my case I've used mallow source and modified a bit and used it, because paraffin needs 3.5 version of .Net.

You can use Mallow

or Paraffin tool to generate WiX fragments: Getting started, The pain of WiX, A better tallow, Paraffin, Download, Paraffin for WiX 3.0

Thylacine answered 5/1, 2009 at 23:18 Comment(1)
Nice little links there Sundar. Thanks a lot. I edited the answer to make it the complete official answer.Samuelson
B
19

I've been using heat.exe in WIX 3.5 just for that purpose. Last time I checked though, the documentation wasn't up-to-date with 3.5 release so keep that in mind.

Here is an example:

"$(WIX)bin\heat.exe" dir "$(SourcePath)" -cg MyFiles -gg -scom -sreg -sfrag -dr INSTALLDIR -out "$(ProjectDir)Fragments\FileFragment.wxs" -var wix.InstallerPath

Bemire answered 25/4, 2011 at 21:4 Comment(0)
C
4

The MapGuide Open Source project is currently using John Robbins' Paraffin 3.0 as others have pointed to.

Basically, the first time through for a given release version, we'll run our installer script with a "generate" action that creates new .wxs files for source folder with specific options for each one.

On subsequent builds of the same version, the "regen" action is called to ensure that the .wxs files are updated with any new files/directories that have been added.

I believe that Heat v3 also now allows you to do a lot (or maybe all?) of this, as Brian Rogers writes . I still feel more comfortable with the way that Paraffin does this more explicitly by maintaining static GUIDs, but the current Heat looks like a good option.

Compendium answered 29/4, 2009 at 23:28 Comment(1)
Example: <Target Name="BeforeBuild"><HeatDirectory OutputFile="$(ProjectDir)\files.wxs" PreprocessorVariable="var.MyProject.TargetDir" ComponentGroupName="MainProject" SuppressUniqueIds="false" Directory="var.MyProject.TargetDir" DirectoryRefId="INSTALLDIR" AutoGenerateGuids="true" SuppressRegistry="true" SuppressRootDirectory="true" ToolPath="$(WixToolPath)" NoLogo="true" /></TargetName>. Inside Project.WixProj. Replace "MyProject" with the project you want to include it's compiled files from. You to add the project as a reference in your wix project for var.MyProject.TargetDir to exist.Frigid
S
3

After further research, it seems there is an included binary called tallow.exe that does just that. It creates a fragment from a directory by recursively searching for files.

Samuelson answered 5/1, 2009 at 22:31 Comment(1)
Oh, you learn something new every day! I didn't realize tallow did that. =)Peng
P
-1

In my use of WIX, I have never come across a feature that lets you add a whole directory of files at a time. This is because there are many ways a given file can be used (the system doesn't know if you'll later want to refer to a specific file in that folder, etc... and it needs to know them), and also because the install itself needs to be pretty specific.

That doesn't stop you from writing your own frontend for WIX that will generate the WIX XML file (or portions of it) after parsing through a directory structures' contents. That's basically what one of the systems we use at my work does. It's the same idea as any code or text file generation utility. Just traverse through the tree, and generate the appropriate text.

EDIT: In that way, you can consider WIX to be the "low-level language" for defining the setup, and your utility as the "high-level language". If you need help writing one, let us know.

Also, you can have the WIX file be generated as part of the build process by adding this utility to the custom build steps in VStudio. That way you don't actually have a "saved WIX file" that anyone builds, the system just builds it at the end, automatically taking new files into account at the post-build step.

Peng answered 5/1, 2009 at 22:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.