1

I'd like to parse merge module files into two different locations. Is it possible?

    <Directory Id="TARGETDIR" Name="SourceDir">
        <Directory Id="MergeRedirectFolder">

        <Component Id="LoggerClient" Guid="*">
          <File Id="log4net" Name="log4net.dll" Source="..\..\_Release\log4net.dll" KeyPath='yes' />
          <File Id="LoggerLibrary" Name="LoggerLibrary.dll" Source="..\..\_$(var.Configuration)\LoggerLibrary.dll" />
          <File Id="app.config" Name="app.config.xml" Source="..\..\_Release\app.config.xml" />
          <File Id="msvcr110.dll" Name="msvcr110.dll" Source="c:\windows\sysWoW64\msvcr110.dll" />
        </Component>

  </Directory>
    </Directory>
</Module>



<Merge Id ="MergeModule.msm" Language ="!(loc.Lang)" SourceFile ="_$(var.Configuration)\MergeModule.msm" DiskId ="1" />

I want the second file to copy to a different folder than the other files.

sirdank
  • 2,704
  • 2
  • 20
  • 45
Dan Bitton
  • 11
  • 3
  • Not sure if I understood correctly - you can set different target destinations for each file in a merge module. If you use Wix I would use Wix include files instead - it has the same effect as a merge module, but is more flexible. – Stein Åsmul May 05 '15 at 12:58
  • To get familiar with Wix try these suggestions: [Getting familiar with Wix](http://stackoverflow.com/questions/25004226/msi-vs-nuget-packages-which-are-is-better-for-continuous-delivery/25005864#25005864). You can also try to decompile a complex merge module *.msm file to see if it creates Wix XML that you can use to adapt to your purpose. (not sure if Wix can decompile msm files, but it can decompile msi files). – Stein Åsmul May 05 '15 at 13:00
  • There is also a template in visual studio to start a merge module project, but I guess you found that already. – Stein Åsmul May 05 '15 at 13:06
  • Your example breaks at least 2 component rules. You can't have multiple DLL's in a single component and a single component can't install to multiple directories. – Christopher Painter May 05 '15 at 15:18

4 Answers4

1

There is a concept for that, it is called a retargetable merge module. I have avoided used it - the concept doesn't seem right to me. I have not tried to make one with Wix.

I think you could combine a Wix include file (simple sample) with the new auto-generated component guids to deploy such duplicated files reliably by adding an Include statement where appropriate. You must not hard code the guids in this case, but let them be auto generated by the Wix compiler and linker.

Also have a read of WixLibs (Wix library files): http://robmensching.com/blog/posts/2008/10/10/what-are-.wixlibs-and-why-would-you-use-them/

Wix documentation; http://wixtoolset.org/documentation/manual/v3/overview/files.html

Community
  • 1
  • 1
Stein Åsmul
  • 34,628
  • 23
  • 78
  • 140
  • 2
    Personally I use merge modules so that I can interop with other Windows Installer authoring tools. Wixlibs are lighter weight but are specific to WiX. – Christopher Painter May 05 '15 at 18:13
0

Merge modules are for installing common runtimes and genuinly shared files. Typically C and C++ runtimes and other, similar libraries that should be available in the latest version for all applications.

Your files look like they are part of your application folder, with the exception of msvcr110.dll which you should remove and allow to be loaded from the system folder.

If the remaining files have no per-machine registration (COM for example or COM Interop), you can duplicate them in several folders without interference, yes, but why not load them from a shared location inside your own application folder structure?

  • %ProgramFiles%\My Company\My Shared Runtimes
  • %ProgramFiles%\My Company\My Apps\My App 1\
  • %ProgramFiles%\My Company\My Apps\My App 2\

These sample folders you "own" and you can deploy things here however you like. Not so for shared, system folders. You could make your own merge module for shared components between your applications into "My Shared Runtimes" and make your applications aware of the shared location "....\MySharedRuntimes\"

Stein Åsmul
  • 34,628
  • 23
  • 78
  • 140
  • thanks for your fast replay , however i want to use one merge module while each file will be set into different folder – Dan Bitton May 05 '15 at 09:32
  • Stein, I disagree with your "geniunly" shared files statement. Merge modules make a great paradigm for encapsulating collections of components for creating distributed installer sources (think AGILE). In fact, that's about the only thing I use them for these days. Merge Modules failed so bad a true shared scenarios that it is very often best to not use them for that. – Christopher Painter May 05 '15 at 15:16
  • I don't use merge modules at all except for shared components from Microsoft not packaged in other ways. Otherwise I prefer to use include files in Wix. – Stein Åsmul May 05 '15 at 15:56
0

It depends on what you mean by different locations. You can build a merge module with 4 files, each in their own component and directory. One could go to the CommonFilesFolder; another to the SystemFolder; another to...you get the idea. So it's potentially easy if you make each file its own component in its own directory. However you've got them all under TARGETDIR, so you're going the wrong direction. You just define the other directory and that other component and file and you might be done, unless there's more to the question than meets the eye.

PhilDW
  • 19,260
  • 1
  • 14
  • 23
-1

I would suggest contacting me privately for a few 30-60 minute conversation on MSI, component rules, Merge Modules and file set theory. It's too much to write. In a nutshell I would advise more merge modules.

Christopher Painter
  • 52,390
  • 6
  • 60
  • 97