views:

572

answers:

3

In my WiX project I need to install different content for the same file name, based on the OS.

  • If the OS is Windows 7 then the file needs to have content X.
  • If the OS is Windows Vista the file needs to have content Y.

I have thought through a few approaches:

  1. Define two components, one with the content for windows 7 and another with the contents for Vista. Run a custom action based on the OS that overwrites the content for Vista if the OS is Windows 7.

  2. Define two additional features (window7 config and win vista config) have the components target the same file and install the feature conditionally based on OS.

Which is the best approach to take. Any tips, tricks and sample wix to get this going?

+2  A: 

I'd do a slightly modified version of #1. Have two Components. One Conditioned to install on Vista. The other Conditioned to install on Win7. Then I'd have the appropriate file in the appropriate Component. No CustomAction necessary. CustomActions should be avoided at all costs, see: http://robmensching.com/blog/archive/2007/08/17/Zataoca-Custom-actions-are-generally-an-admission-of-failure.aspx

PS: Mark the Components Transitive so that the right content gets installed on an Operating System upgrade.

Rob Mensching
I tried that ... it complained that two different components can not have the same file name ...
Sam Saffron
Complained with an error, or warning? We do the two components method for different registry configurations.
sascha
That should have just been a warning and as long as you know that you are not violating the warning then you can ignore it.
Rob Mensching
I actually get an error: Error 1 ICE30: The target file 'jrf_j-90.xml|Registration.xml' is installed in '[ProgramFilesFolder]\MediaBrowser\MediaBrowser\' by two different components on an LFN system: 'Registration.xml' and 'Registration7.xml'. This breaks component reference counting. C:\Users\sam\Desktop\MediaBrowserSVN\Installer\Setup.wxs 90 1 Installer
Sam Saffron
Im sure the mistake is on my side ...
Sam Saffron
btw .. the wix file im using is at http://github.com/sambo99/Media-Browser/commit/7956186af35abf0be8356a17c0db5ebf0d957297
Sam Saffron
+1  A: 

Another solution would be to install both files, and have the application read from the correct one at runtime. If this is a file that may be later modified by your application then you probably don't want to install it directly anyway, but rather install a "default" that is read if a "per user" file does not exist. In this case when a "per user" file does not exist, read the appropriate OS global defaults and then write those out to the "per user" file on first run (or whenever the particular file doesn't exist).

Sometimes what makes sense during the initial application design doesn't end up translating into a "good" Windows Installer result and you need to modify a few things :)

sascha
yeah, thats what i ended up doing http://github.com/sambo99/Media-Browser/commit/7956186af35abf0be8356a17c0db5ebf0d957297
Sam Saffron
A: 

I am having the same issue. Did you ever figure out how to overcome this issue?

Ozlem
we install both files and conditionally execute base on OS
Sam Saffron