Search code examples
c#.netwpfwindows-installerwix4

WiX Toolset/HeatWave - Add dll to Installer


I'm trying to create a msi-Installer with the WiX Toolset v4 for a HelloWorld WPF-Application. My problem is a missing dll which is not rolled out with the msi installation.

I've just created a WiX MSI Package via the Visual Studio 2022 'MSI Package (WiX v4)'-template and done two steps:

  1. Add a Project Dependency to my HelloWorld WPF Application
  2. Edit the ExampleComponents.wxs and change the Source Attribute from the File-Element to the WPF Applications Name

The wxs-files at this point:

ExampleComponents.wxs

<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
  <Fragment>
    <ComponentGroup Id="ExampleComponents" Directory="INSTALLFOLDER">
      <Component>
        <File Source="WpfApp.exe" />
      </Component>
    </ComponentGroup>
  </Fragment>
</Wix>

Folders.wxs

<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
  <Fragment>
    <StandardDirectory Id="ProgramFiles6432Folder">
      <Directory Id="INSTALLFOLDER" Name="!(bind.Property.Manufacturer) !(bind.Property.ProductName)" />
    </StandardDirectory>
  </Fragment>
</Wix>

Package.wxs

<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
  <Package Name="WpfAppPackage" Manufacturer="TODO Manufacturer" Version="1.0.0.0" UpgradeCode="32058e2f-46ed-4823-9795-d68433888c7f">
    <MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeError)" />

    <Feature Id="Main">
      <ComponentGroupRef Id="ExampleComponents" />
    </Feature>
  </Package>
</Wix>

The build results in a msi, wixpdb and a cab1.cab file. To run the msi file leads to a new folder under C:/Program Files (x86)/... with the WpfApp.exe but I'm expecting the necessary WpfApp.dll as well which is missing at this point.

Trying to start the WpfApp.exe leads to nothing but an Eventlog-Entry which confirms my assumption.

So how do I configure my project for adding the dll in the installation process?


Solution

  • You'll want to update your components that you're telling it to install. The easiest way is to manually add the files you're looking to add to the ComponentGroup

    <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
      <Fragment>
        <ComponentGroup Id="ExampleComponents" Directory="INSTALLFOLDER">
          <Component>
            <File Source="WpfApp.exe" />
          </Component>
          <Component>
            <File Source="WpfApp.dll"/>     <!-- Add this line with the path to your other file -->
          </Component>
        </ComponentGroup>
      </Fragment>
    </Wix>