Bundle multiple support files for WiX Burn
Asked Answered
E

2

6

I have a third party MSI that has been supplied to me by a vendor. However the MSI does not stand alone, it requires multiple support files (dll's, config files, device drivers ...) to complete an installation. I've tried to install without these files present in the directory with the MSI and it complains about the missing files during installation. Seems to me this is an odd way to build an installer. Anyway, I'd like to bundle this "installation" to be consumed by Burn. I've used MSIPackage before, but that works for a single file. How would I specify this group of files? I'm tempted to make an new MSI that includes the MSI from the third party plus the additional files, but then I end up with the some phantom program installed which is really not what I want.

Thanks in advance for your help.

EDIT with Solution:

Many Thanks to Tom for the keys to this problem. For those that are curious here is the code and steps I used to solve this problem in WiX 3.8.

First harvest the directory where the third party installer was stored.

"%WIX%bin\heat.exe" dir "$(ProjectDir)..\ThirdParty\AppDirectory" -dr Dir_AppName -cg PAYGROUP_AppName -ag -sreg -scom -srd -var "var.AppNameDir" -t "$(ProjectDir)\ComponentToPayload.xsl" -out "$(ProjectDir)AppNamePayloadGroup.wxs"

Where AppNameDir is a preprocessor variable referencing the location of the app installation files.

My transform file was a little different from the one linked to by Tom, but not much. I created a component group in my orginal heat file and then used that as my PayloadGroup later rather than the DirectoryRef.

<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:wix="http://schemas.microsoft.com/wix/2006/wi"
  xmlns="http://schemas.microsoft.com/wix/2006/wi">

  <xsl:template match="/">
    <Wix>
      <Fragment>
        <xsl:apply-templates select="*" />
      </Fragment>
    </Wix>
  </xsl:template>

  <xsl:template match="//wix:ComponentGroup">
    <PayloadGroup>
      <xsl:attribute name="Id">
        <xsl:value-of select="@Id"/>
      </xsl:attribute>
      <xsl:apply-templates select="*" />
    </PayloadGroup>
  </xsl:template>

  <xsl:template match="//wix:File">
    <Payload>
      <xsl:attribute name="SourceFile">
        <xsl:value-of select="@Source"/>
      </xsl:attribute>
    </Payload>
  </xsl:template>

</xsl:stylesheet>

Then I created a fragment for the component and referenced the Payload group

  <Fragment>
    <PackageGroup Id="PCKGRP_AppName">
      <MsiPackage
        SourceFile="$(var.AppNameDir)\app.msi">
        <MsiProperty Name="PropertyName1" ="Value1"/>
        <MsiProperty Name="PropertyName2" ="Value2"/>
        <MsiProperty Name="PropertyName3" ="Value3"/>
        <PayloadGroupRef Id="PAYGROUP_AppName"/>
      </MsiPackage>
    </PackageGroup>
  </Fragment>

And then finally reference the group in the chain

    <Chain>
...
      <PackageGroupRef Id="PCKGRP_AppName"/>
...
    </Chain>   
Europeanize answered 17/11, 2014 at 21:21 Comment(1)
Thanks for the solution. Adding <xsl:strip-space elements="*" /> to the xsl produces a cleaner result.Empiric
T
4

Inside the MsiPackage element use a bunch of Payload elements (or put the payloads elsewhere and use a PayloadGroupRef).

In compensation, your bootstrapper might get better compression since the MsiPackage is starting out exploded because double compression can be inefficient with time and space.

Trinitrocresol answered 18/11, 2014 at 2:10 Comment(3)
Great suggestion, it has opened some new doors to me. Do you know if heat can actually harvest a directory for generating a payload group. I tried the "-generate payloadgroup" switches but all I got out was components.Europeanize
heat will do an XSL transform on its output. See "FilesToPayloads.xsl" in this answer.Trinitrocresol
Thanks for your help, I incorporated the suggestions and it worked well. Edited original post to show my new code.Europeanize
P
2

Thanks a million for this answer. With help of other posts (especially this one) I came up with xslt to also include Name attribute (with subfolders) and strip empty lines.

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:wix="http://schemas.microsoft.com/wix/2006/wi"
 xmlns="http://schemas.microsoft.com/wix/2006/wi">

<xsl:strip-space elements="*"/>

<xsl:template match="/">
<Wix>
  <Fragment>
    <xsl:apply-templates select="*" />
  </Fragment>
</Wix>
</xsl:template>

<xsl:template match="//wix:ComponentGroup">
<PayloadGroup>
  <xsl:attribute name="Id">
    <xsl:value-of select="@Id"/>
  </xsl:attribute>
  <xsl:apply-templates select="*" />
</PayloadGroup>
</xsl:template>

<xsl:template match="//wix:File">
<Payload>
  <xsl:attribute name="SourceFile">
    <xsl:value-of select="@Source"/>
  </xsl:attribute>
  <xsl:attribute name="Name">
    <xsl:call-template name="string-replace-all">
      <xsl:with-param name="text" select="@Source"/>
      <xsl:with-param name="replace" select="'$(var.SourceDir)\'"/>
      <xsl:with-param name="by" select="''"/>
    </xsl:call-template>
  </xsl:attribute>
</Payload>
</xsl:template>

<xsl:template name="string-replace-all">
<xsl:param name="text" />
<xsl:param name="replace" />
<xsl:param name="by" />
<xsl:choose>
  <xsl:when test="contains($text, $replace)">
    <xsl:value-of select="substring-before($text,$replace)" />
    <xsl:value-of select="$by" />
    <xsl:call-template name="string-replace-all">
      <xsl:with-param name="text"
      select="substring-after($text,$replace)" />
      <xsl:with-param name="replace" select="$replace" />
      <xsl:with-param name="by" select="$by" />
    </xsl:call-template>
  </xsl:when>
  <xsl:otherwise>
    <xsl:value-of select="$text" />
  </xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

I hope this will help you to automate Wix bootstapper builds.

Positron answered 20/11, 2015 at 19:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.