3

Consider the following scenario:

  • Project CommonLib
    • CommonLib.dll
  • Project AExe
    • CommonLib.dll
    • AExe.exe
  • Project BExe
    • CommonLib.dll
    • BExe.exe

Project AExe is installed in %ProgramFiles%\AExe\bin and BExe %ProgramFiles%\BExe\bin but both are deployed using the same .MSI

How can I declare the CommonLib.dll as a generic component and then reuse it in AExe Directory[Ref] and BExe Directory[Ref] ?

What I would like do:

<Fragment>
<Component Id="C.CommonLib.dll" Guid="*">
  <File Id="Fi.CommonLib.dll" Source="<path>CommonLib.dll" KeyPath="yes"/>
</Component>
<Directory Id="ProgramFilesFolder">
  <Directory Id="Di.AExe" Name="AExe">
    <Directory Id="Di.AExeBin" Name="bin">
      <ComponentRef Id="C.CommonLib.dll"/>
    </Directory>
  </Directory>
  <Directory Id="Di.BExe" Name="BExe">
    <Directory Id="Di.BExeBin" Name="bin">
      <ComponentRef Id="C.CommonLib.dll"/>
    </Directory>
  </Directory>
</Directory>
</Fragment>

But that doesn't work because Directory doesn't allow a Ref as child. How would you code that?

P.S: I give the example with 2 projects but in reality there is much more projects that shares more than one common lib, that's why I'm asking that :)

Arnaud F.
  • 8,252
  • 11
  • 53
  • 102
  • Appears to be a duplicate of http://stackoverflow.com/questions/4941602/features-installed-to-different-locations-but-referencing-the-same-components – Zach Young Feb 28 '12 at 19:13

1 Answers1

1

As you can tell from the Windows Installer Component table, components can only be associated with one directory. However, nothing is stopping you from creating two different components which install the same file:

<Component Id="CommonLib.dll.1" Directory="Di.AExeBin">
  <File Id="CommonLib.dll.1" Source="...\CommonLib.dll"/>
</Component>

<Component Id="CommonLib.dll.2" Directory="Di.BExeBin">
  <File Id="CommonLib.dll.2" Source="...\CommonLib.dll"/>
</Component>

(Note: my example is for wix3 where you can use a Directory="..." attribute, but of course you can also still put the components under Directory parent elements.)

Wim Coenen
  • 66,094
  • 13
  • 157
  • 251
  • 4
    Yes, I know that I can do that, and I doing it like this now, wanted just to know if there is a better way to reuse components – Arnaud F. Feb 29 '12 at 07:47