Skip to content

Bundle Source

Richard Martin edited this page Mar 23, 2024 · 3 revisions

Defining a Bundle

Bundle.wxs (.NET Framework) || (.NET Core)

At the very top, you'll find a namespace reference for the WiX bootstrapper application layer.

xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal"

That's followed by definitions for a few variables that will be referenced in the rest of the source.

There's a definition for the format of the file name for log files emitted when the bundle is run. I've placed the bundle's version in the file name to make it easier to tell which bundle generated which log during an update.

<Log Prefix =".\$(var.ProductName)_$(var.ProductVersion)" Extension="log" />

Bundle Element

The Bundle defines the structure of the bundle that will be built. The BootstrapperApplication is declared inside the Bundle.

.NET Framework - Specifying the BA

We reference WixManagedBootstrapperApplicationHost, which tells the WiX bundle that our BA is targeting .NET Framework.

<BootstrapperApplication bal:CommandLineVariables="caseInsensitive">

  <bal:WixManagedBootstrapperApplicationHost />
      
  ...
      
</BootstrapperApplication>

After this, we can add files to the bundle's payload that will be included in addition to the files referenced in the Chain. Since we've referenced the managed app host, we need to include at least one DLL where our BA can be found. In our case, this is boostrapper.dll. Since many files can be included as payload, we also need to let WiX know which file contains a factory that can construct our BA. That's done by including the BAFactoryAssembly attribute. The factory will be covered when we look at the Bootstrapper project.

<Payload SourceFile="$(var.Bootstrapper.TargetDir)Bootstrapper.dll" bal:BAFactoryAssembly="yes"/>

But our DLL has some dependencies, so we need to make sure they are packed into the bundle as well. That's done by adding as many Payloads you need.

<Payload SourceFile="$(var.Bootstrapper.TargetDir)mbanative.dll"/>
<Payload SourceFile="$(var.Bootstrapper.TargetDir)WixToolset.Mba.Core.dll"/>
<Payload SourceFile="$(var.Bootstrapper.TargetDir)WixToolset.Mba.Host.config"/>

.NET Core - Specifying the BA

We reference WixDotNetCoreBootstrapperApplicationHost, which tells the WiX bundle that our BA is targeting .NET Core.

<BootstrapperApplication bal:CommandLineVariables="caseInsensitive">

    <bal:WixDotNetCoreBootstrapperApplicationHost SelfContainedDeployment="yes" />
      
    ...
      
</BootstrapperApplication>

After this, we add the BA's files to the bundle's payload. In Bundle.wixproj, we used Heat to harvest the Bootstrapper assembly and all its dependencies. We'll use a PayloadGroupRef to reference the PayloadGroup that Heat produced.

<PayloadGroupRef Id="BA.publish" />

Chain Element

I'm going to gloss over the Chain because there's a lot of WiX 3 help and tutorials that cover declaring a chain of packages. There's tons of functionality available to you; too much to be covered here. I will add that with v4, you need to include the PrereqPackage attribute to make sure the packages you deploy are included in the plan.

Previous: Solution Overview || Next: Bootstrapper Overview

Clone this wiki locally