1

Similiar question: Reusing WIX components to speed up candle/light

My project has the very same problem as the one referenced; a very large static database that never changes is compressed into the msi every time a build is required. I would like to do as the question asks: reuse a pre-compressed cab file to speed up the build time.

I started doing as the answer suggests, using the cabCache property. I added the following to the .wixproj:

<CabinetCachePath>cabs</CabinetCachePath>
<ReuseCabinetCache>True</ReuseCabinetCache>

I then seperated the static data into a fragment:

<Fragmet>
  <Media Id="2" Cabinet="static.cab" EmbedCab="no" />
  <Component Id="staticCab" Guid="..." >
    Files ...
  </Component>

And the fragment was referenced in the feature:

<ComponentRef Id="staticCab" />

This created the cab file, but left it empty. My next thought was the use a Merge Module. I created the module:

<Module Id="StaticModule" Language="1033" Version="1.0.0.0" >
  <Package ...>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="MergeRedirectFolder" Name=".">
        <Component Id="StaticFiles" Guid="...">
          Files...
        </ -- End all XML Tags

And then merged it:

<Directory Id="StaticDir" Name="static">
  <Merge Id="StaticModule" Language="1033" src="..\Static\bin\Release\static.msm" />
</Directory>

<Feature ...>
  <MergeRef Id="StaticModule"/>
</Feature>

Even after all this, the CabinetCache is still being rebuilt every time.

I guess my question would be what is the correct way to use ReuseCabinetCache. I'm still learning WIX, so I apologize if the answer is evident. I just am not sure how to use it.

Edit: A MergeModule would not be ideal since there is no need to share that logic with other msi's. It is only useful to this single project to a single development team.

Community
  • 1
  • 1
SaulBack
  • 1,406
  • 2
  • 16
  • 31

1 Answers1

5

I'm going to go ahead and answer my own question since it turned out to be so simple.

Change the .wxiproj to have these properties in

<CabinetCachePath>cabs</CabinetCachePath>
<ReuseCabinetCache>True</ReuseCabinetCache>

Add a media to the .wxs install

<Media Id="2" Cabinet="static.cab" EmbedCab="yes" />

In the Directory tag where you store the static files, add DiskId="2".

This will do a couple of things. First you are telling Wix that you wan't to store the cabinets in a path to reuse the cabinets. Creating a new cabinet and only storing static data in it (or data that doesn't change often) will cause Wix to use the cached version of the cabinet. Wix validates the cabinets by ensuring that:

  • The number of files in the cached cabinet matches the number of files being built.
  • The names of the files are all identical.
  • The order of files is identical.
  • The timestamps for all files all identical.

(Source: http://wix.sourceforge.net/manual-wix3/optimizing_builds.htm)

No wonder I couldn't find any documentation on it. Its so easy to do it should have been apparent to me.

Update: Also, multiple threads are used to build multiple cabinets. Creating multiple cabinets will improve the speed even more.

SaulBack
  • 1,406
  • 2
  • 16
  • 31