views:

1790

answers:

3

I'm using the VS2008 installer (plus a custom Orca action) to create an installer for my .NET product.

I just recently found out that one of the third-party assemblies I was using is x86-specific (as it includes some native code); thus, x64 customers were getting crashes on startup with errors about the assembly not being appropriate for their platform.

I sent such a customer a copy of the x64 version of this third-party assembly, and told him to just copy it over the existing x86 one. It worked, sweet! So now I just need to make the installer do this for me.

This actually appears nontrivial :(. Ideally, I just want the installer (which would be x86, since that can run on both platforms) to include both the x86 and x64 versions of this third-party assembly, and install the appropriate one. In other words, I want a single installer that makes my users' lives easy.

I thought I had this worked out, using MSI conditional statements and all that. But apparently no... the VS2008 setup projects won't compile unless you specify "x86" or "x64." If you specify x86, it gives a compilation error saying it can't include the x64 assembly. If you specify x64, then the result cannot be executed on an x86 computer. Damn!

Someone must have had this problem before. Unfortunately Google is unhelpful, so I turn to StackOverflow!

+6  A: 

When I looked into this a year ago, I came to the conclusion that it was not possible. It's worth noting that many Microsoft-supplied MSI files come in separate x86 and x64 flavors -- and presumably, they'd only deliver a single file if that were possible.

Curt Hagenlocher
+1  A: 

I have had some success by using two features to selectively include the two sets of files (in separate components of course, with their individualized file identifiers!).

The installation must be marked as x32 to install on both x32 and x64. It will always install to the x32 directories and will largely be treated as a 32 bit application running under WOW.

Using the VersionNT64 property you can determine if a Windows 64 installation is present, and conditionally install the files you need.

I'm not sure how much of this functionality is available in VS2008 install projects - I am using some other commercial tools to set up the installer this way. Of course you can use Orca to do it too, though it was non-trivial to get it to work with commercial tools and Orca is much harder.

Rob Hunter
+4  A: 

If I understand you correctly, you want to do a copy of one file if you're installing on x86 and different file (with the same name) if you're installing on a x64 platform.

First of all, you cannot create one MSI for 2 different platforms, since a x64 MSI simply will not run on a x86 platform and a x86 MSI will be installed using WOW64 on a x64 platform.

On the other hand, you CAN create one x86 MSI that contains 2 different versions of a file and selectively copy the appropiate file during installation.

The easiest way is using WIX (V3) instead of the build-in VS2008 MSI generator. WIX gives you far greater control over what gets installed on the customer's machine and where, the ability to generate different installers for different platforms and full MSBuild support as an added bonus. (see http://wix.sourceforge.net for more info.)

In case if you're wondering that WIX is still in Beta, the generated MSI files are perfectly OK and I never ran into a bug yet. (And I develop setup projects for a living.)

Finally, you can check with the VersionNT64 property if an x86 installer is running on a x64 platform. If that property is present, you're running x64, otherwise you're running on a x86.

Hope this helps.

Jeroen Landheer
Thank you; this is the best solution, I'd think.When you say "a x86 MSI will be installed using WOW64 on a x64 platform," would this mean my application would end up being WOW64'ed? And I presume that's bad.So in the end I might have some kind of boostrapper to choose between MSIs?
Domenic
"would this mean my application would end up being WOW64'ed?" - Yes, it would mean exactly that. Your application will run as a 32-bit process on a 64-bit machine because it's installed in the "Program files (x86)" folder. A x86 bootstrapper is indeed a solution which you can use to selectively start the appropiate MSI.
Jeroen Landheer