Search code examples
githubwixgithub-actionswindows-installerwix3.11

Use multiple .wxs files to create .msi in a GitHub workflow (WiX Toolset)


I want to create an .msi file using the WiX Toolset within a GitHub Action. Since I generate a .wxs file (Components.wxs) using the "heat" command, I have two files (Components.wxs and Product.wxs) that need to be used during compilation. Unfortunately, the reference to the Components.wxs file is not working.

The Components.wxs file look kinder:

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>
        <DirectoryRef Id="PATH">
            <Component Id="SOMEDLL.dll" Guid="*">
                <File Id="SOMEDLL.dll" KeyPath="yes"
                      Source="SourceDir\SOMEPATH" />
            </Component>
        </DirectoryRef>
    </Fragment>
<Fragment>
    <ComponentGroup Id="Components">
            <ComponentRef Id="SOMEDLL.dll" />
    </ComponentGroup>
</Fragment>

Initially, I attempted to directly use a ComponentGroupRef with the respective Id from the Components.wxs file within my Product tag in the Product.wxs.

<Feature Id="ProductFeature" 
     Title="Setup" 
     Level="1">
    <ComponentGroupRef Id="Components" />
</Feature>

However, this consistently resulted in the error Product.wxs(21) : error LGHT0094 : Unresolved reference to symbol 'WixComponentGroup:Components' in section 'Product:*'.

Subsequently, I tried adding the following tag to the ItemGroup section in the Setup.wixproj: <Compile Include="Components.wxs" />. However, this did not bring about any changes.

Now, I attempted to include a .wxi file in the project, which is included in the Product.wxs and references the ComponentGroup in the Components.wxs file. Unfortunately, I encountered an error stating that the ComponentGroupRef tag is not allowed.

IncludeComponents.wxi:

<?xml version="1.0" encoding="utf-8"?>
<Include>
    <ComponentGroupRef Id="Components" />
</Include>

In the Product.wxs:

<Feature Id="ProductFeature" 
     Title="Setup" 
     Level="1">
    <ComponentGroupRef Id="Components" />
</Feature>

Error: IncludeComponents.wxi(3) : error CNDL0005 : The Wix element contains an unexpected child element "ComponentGroupRef".

Here is the run-block in the GitHub action:

run: |
  cd Setup
  C:\wix\heat.exe dir ..\publishData -ag -dr PublishData -srd -sfrag -suid -cg Components -out Components.wxs
  C:\wix\candle.exe -ext C:\wix\WixIIsExtension.dll -ext C:\wix\WixUIExtension.dll Components.wxs Product.wxs 
  C:\wix\light.exe Product.wixobj -ext C:\wix\WixIIsExtension.dll -ext C:\wix\WixUIExtension.dll -out MySetup.msi

I have no idea why this is not working, and after a day, I've reached the limit of my patience. Can someone please tell me how to properly reference another .wxs file within the Product.wxs file? Thanks for any help.


Solution

  • I found the error. In the light command the Components.wixobj had to be included before the Product.wixobj.