-
Notifications
You must be signed in to change notification settings - Fork 3
Bundle Project
Bundle.wixproj (.NET Framework) || (.NET Core)
In the first PropertyGroup
, you'll find
<Platforms>x64</Platforms>
<InstallerPlatform>x64</InstallerPlatform>
You select which architectures your project will support in Platforms
with a semi-colon delimited list. Here, only one architecture is specified. In InstallerPlatform
, you select which of the Platforms
to build. There's only one, so that's specified.
You'll find a ProjectReference
to the Bootstrapper project. This isn't necessary, but sets up some WiX variables that can help when working in the bundle's source code.
There's a PackageReference
to the WixToolset.Bal.wixext NuGet package.
I personally like to suppress debug files when doing a release build. WiX has its own SuppressPdbOutput
property. If that interests you, you can add a property group which applies when the Condition
matches a release build.
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<SuppressPdbOutput>True</SuppressPdbOutput>
</PropertyGroup>
For the .NET Core solution in this tutorial, we're publishing the BA using the dotnet -self-contained
flag. By doing this, we don't have to pre-install .NET before our installer can run. This isn't required, but I feel it's a good option when running a .NET Core BA. If the BA isn't self contained, then the end user will be prompted to download and install .NET when the bundle is run. It's an OK user experience, but not great. The downside is that this will bloat the bundle's size significantly. It takes noticeably longer to extract the BA from the bundle before it is run. You can cover this up by using a splash screen, but that's just a band aid.
If we're building a self-contained app, the bundle will need to include all these files for our BA to run successfully. Thankfully, we can use Heat to harvest the publish folder.
In addition to the WixToolset.Bal.wixext NuGet package, add a reference to WixToolset.Heat.
<ItemGroup>
<PackageReference Include="WixToolset.Bal.wixext" Version="4.*" />
<PackageReference Include="WixToolset.Heat" Version="4.*" />
</ItemGroup>
We also want a project reference to the Bootstrapper project.
<ItemGroup>
<ProjectReference Include="..\Bootstrapper\Bootstrapper.csproj" />
</ItemGroup>
Have Heat produce a PayloadGroup for the bundle by adding this config to a PropertyGroup
.
<HarvestDirectoryAdditionalOptions>-generate payloadgroup</HarvestDirectoryAdditionalOptions>
In an ItemGroup
, configure Heat's harvest folder. This will be the folder the Bootstrapper project is published to. Add a DirectoryRef
so that the PayloadGroup
can be referenced in Bundle.wxs. We'll use an XSLT transform (ba.xslt) to add the BAFactoryAssembly
attribute to the BA's assembly (bootstrapper.dll) during the harvest.
<ItemGroup>
<BindInputPaths Include="..\Bootstrapper\bin\publish" />
<HarvestDirectory Include="..\Bootstrapper\bin\publish">
<DirectoryRefId>BA.publish</DirectoryRefId>
<Transforms>ba.xslt</Transforms>
</HarvestDirectory>
</ItemGroup>
Heat can't do its job unless the Bootstrapper project is published. So, let's add an msbuild target to take care of this before the bundle is built.
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="dotnet publish "..\Bootstrapper\Bootstrapper.csproj" -o "..\Bootstrapper\bin\publish" -r win-x64 -c $(Configuration) --self-contained true" />
</Target>