Search code examples
wixwix3.5

DirectoryRef: use in 2 different folders


In my installer project I have a harvested output of a referenced project which creates a fragment and, inside it, DirectoryRef element.

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>
        <DirectoryRef Id="MyProject.Content">
            <Directory Id="dir9B0F2CD8423EA8141263E4CAA24D1234" Name="Data">
    <!-- subfolders, components etc. -->

Now, in my main wxs file I need to include MyProject.Content directory as a subfolder of two different directories.

I include <Directory Id="MyProject.Content" /> as a child of one directory and it works fine, files are added.

But if I include it in another directory I get:

error LGHT0091: Duplicate symbol 'Directory:MyProject.Content' found.

How can I reuse DirectoryRef twice?


Solution

  • The Id of non-Ref elements must be unique. So, somewhere in your .wxs code you have Directory Id='MyProject.Content' twice.

    Unfortunately, the design of heat.exe that is part of the WiX Toolset adds a lot of identifiers preventing your scenario. You'd need to remove the Id attributes and probably still have to harvest twice to get two different ComponentGroup identifiers. This scenario just isn't in the design of heat.exe.

    Contrast that with something like the WiX Expansion Pack advanced harvesting's solution where the HarvestFolder or HarvestProject element is placed directly in your .wxs code. Then you can place those elements in the appropriate directories and unique identifiers will be generated.