Wix Bundle Source Path and Project Structure

I am trying to create a Bootstrapper installer that will install My app plus one third party apps required to run my app.

The third application is an .exe package with many additional files.

My question is, how do I include a third party app in my Bundle? Am I adding all full access files (100+ files) as payload?

the code below is how I have installed my Bundle so far, it compiles but not install, the log says bootstrapper.exe cannot find my .msi (my application) or .exe (third party application)

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
     xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
    <Bundle Name="My_app"
            Version="1.0.0.0"
            Manufacturer="untitled"
            UpgradeCode="4d2de235-2286-4b06-8cfa-3f6ff3174244">

        <BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense" />

        <Chain>
            <MsiPackage
                Id="MyApp_msi"
                SourceFile ="MyApp\MyApp.msi"
                Vital ="yes"/>
            <PackageGroupRef Id="thirdParty_package" />
        </Chain>
    </Bundle>

    <Fragment>
        <PackageGroup Id="thirdParty_package">
            <ExePackage
                SourceFile="thirdParty\Setup.exe"
                InstallCommand="/q /ACTION=Install"
                RepairCommand="/q ACTION=Repair /hideconsole"
                UninstallCommand="/q ACTION=Uninstall /hideconsole"/>
        </PackageGroup>
    </Fragment>
</Wix>

      

+2


source to share


2 answers


Yes, you need to list each payload. It is convenient to place them in PayloadGroup.

There are several ways to create a PayloadGroup. One way is to use / abuse heat to build a catalog. This will be the same as collecting the directory for the setup project.

As an example, let the WiX bin batch directory.

  <ExePackage Id="MyPackageId" SourceFile="$(env.WiX)bin/dark.exe" Compressed="yes">
    <PayloadGroupRef Id="MyPayloadGroupId"/>
  </ExePackage>

      

If you are using MSBuild (including through Visual Studio), you can customize harvesting by adding something like this to your project file:

  <ItemGroup>
    <HarvestDirectory Include="$(WIX)/bin">
      <ComponentGroupName>MyPayloadGroupId</ComponentGroupName>
      <PreprocessorVariable>var.MyPayloadSourceDirectory</PreprocessorVariable>
      <Transforms>FilesToPayloads.xsl</Transforms>
      <SuppressRegistry>true</SuppressRegistry>
      <!-- Hide from VS Solution Explorer -->
      <InProject>false</InProject>
    </HarvestDirectory>
  </ItemGroup>

      



When the assembly starts, it adds the output .wsx (in obj) to the assembly. (You don't need to see this.)

Note that it uses a preprocessor variable to give the actual location of the source files. To pass a value, define it in the project properties. Or, as XML in .wixproj:

<DefineConstants>Debug;MyPayloadSourceDirectory=C:/Program Files (x86)/WiX Toolset v3.8/bin</DefineConstants>

      

Finally, the XSL transform (FilesToPayloads.xsl) that heats up will be applied to its normal crop:

<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:DirectoryRef">
    <PayloadGroup>
      <xsl:attribute name="Id">
        <xsl:value-of select="/wix:Wix/wix:Fragment/wix:ComponentGroup/@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>

      

This is a rather trivial transliteration of the payload file and surrounding DirectoryRef in the PayloadGroup.

+2


source


Agreed, it's a pain to manually generate the payload for installers with a lot of files! Here is a small powershell script to generate xml payload given a path. It will generate hints to use as id, overwrite the folder and reproduce the folder structure.



if($args.Length -eq 0) {
    Write-Host "Error: No argument. Supply path to payload folder as script argument."
    Exit 1
}
$path = $args[0]
foreach($file in Get-ChildItem -Name $path -File -Recurse)
{
    Write-Host ("<Payload Id=`"" + ([guid]::NewGuid()) + "`" SourceFile=`"" + (Join-Path -Path $path -ChildPath $file) + "`" Name=`"" + $file + "`" />")
}

      

0


source







All Articles