Search code examples
wixwindows-installerwix3.7merge-module

Can I use auto-generated GUIDS with a merge module?


I use auto-guids in my <Product> but can't figure out how to use them with <Module>. I only get this error:

The component X has a key file with path 'TARGETDIR\company...'. Since this path is not rooted in one of the standard directories (like ProgramFiles Folder), the component does not meet the criteria for having an automatically generated guid.

Above, company is the value mapped to !(loc.ProductManufacturerFolderName).

The only problem is that's not true. My directories are rooted in ProgramFiles just like my product is and my product works fine:

<Directory Id="TARGETDIR" Name="SourceDir">
    <Directory Id="ProgramFiles64Folder">
        <Directory Id="MODULEINSTALLLOCATION" Name="!(loc.ProductManufacturerFolderName)">
            <Directory Id="Data" Name="Data">

All my component declarations look roughly like this:

<Component Id="DocumentationParty_Business_TestCases_v1xlsx.component" Guid="{YOURGUID-1234-1234-84B3-C595A63428AD}" MultiInstance="yes">
    <File Source="../../Development/Integration/SSIS/Documentation/Party_Business_Test Cases_v1.xlsx" KeyPath="yes" Id="DocumentationParty_Business_TestCases_v1xlsx.file" />
</Component>

Breaking it is easy, you only have to change the GUID to * and the above error results. This is broken:

<Component Id="DocumentationParty_Business_TestCases_v1xlsx.component" Guid="*" MultiInstance="yes">
    <File Source="../../Development/ClaimsIntegration/SSIS/Documentation/Party_Business_Test Cases_v1.xlsx" KeyPath="yes" Id="DocumentationParty_Business_TestCases_v1xlsx.file" />
</Component>

I have a .wxs file for each directory to which components will be installed. All my component-holding .wxs files have the following structure:

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Fragment>
    <ComponentGroup Id="DatabasePolicy_Files">
      <ComponentRef Id="DatabasePolicyCreateDatabasecmdtemplate.component" />
    </ComponentGroup>
    <DirectoryRef Id="DataPolicy">
      <Component Id="DatabasePolicyCreateDatabasecmdtemplate.component" Guid="*" MultiInstance="yes">
        <File Source="../../Development/Database/Policy/CreateDatabase.cmd.template" KeyPath="yes" Id="DatabasePolicyCreateDatabasecmdtemplate.file" />
      </Component>
    </DirectoryRef>
  </Fragment>
</Wix>

Each <ComponentGroup> is included in my master .wxs file through a <ComponentGroupRef>. This works in all my MSI projects and breaks only now that I've started working with merge modules. Also, I've tried commenting out all components except for which matches the above definition and it still breaks on the same error.

What is the problem?


Solution

  • I've had this similar issue myself and based on your error message it's probably the same. Try adding a ComponentGuidGenerationSeed, that should solve your issue. The ComponentGuidGenerationSeed acts on all subfolders as well so a single one at the top-level is sufficient for all folders.

    Example:

    <Directory Id="DOCUMENTATIONFOLDER" Name="Documentation" ComponentGuidGenerationSeed="a9f690d3-22b3-488f-bdac-bb665c25933c"/>
    

    http://wixtoolset.org/documentation/manual/v3/xsd/wix/directory.html

    The Component Guid Generation Seed is a guid that must be used when a Component with the generate guid directive ("*") is not rooted in a standard Windows Installer directory (for example, ProgramFilesFolder or CommonFilesFolder).