How to implement single installer for 32 & 64 plat

2019-02-02 06:04发布

问题:

I work on an WIX based installer.

The installer builds to 32 and 64 platforms separately. The installers versions are very similar in both platforms but few conditional steps like avoid registering x64 native dlls in the 32 bit installer.

Is there a way to unite both of the installers to one?

回答1:

It can't be done. It's a limitation of Windows Installer, if you want to do this without making it twice as large, then you'll need two MSI's with external CAB files and a bootstrapper to execute the correct installation.

If you don't need an MSI, try NSIS. You can do conditional installation based on OS architecture pretty easily.

Anyway, this has been also asked on the WiX-users list a number of times in recent weeks, the best response I can find is this one from Blair:

An MSI marked as 64-bit simply will not install on a 32-bit system. Nothing you can do.

An MSI marked as 32-bit simply cannot place files into a "64-bit directory" (they will be redirected to 32-bit "equivalent" folders). Nothing you can do.

An MSI cannot be marked as both 32- and 64-bit. Also nothing you can do.

The "correct" method is to generate two MSIs, one for 32-bit platforms and another for 64-bit platforms. They can share the same external cab files if you need to ship them together to save space. If you do that, you can use a bootstrapper to extract the appropriate one with your CAB(s) and install it.



回答2:

It is possible, to an extent. You can't do it with an MSI alone, though. An example of this is Microsoft's .NET installer packages; the "full install" package has x86 bit, x64 bit, and ia64 support. However, this installer uses a bootstrapping process to do it; it has a separate program that determines exactly what to install, and then installs it. Underneath, you still need the 32 bit MSI and the 64 bit MSI packages.

Be warned though; the architecture of your installer's bootstrapper will then determine what it can be installed on. If it's an x86 based bootstrapper, then it will only work on 32 bit windows and 64 bit windows that have WOW64 installed (a removable option with Win2k8 R2) and may not work at all on ia64 platforms!

It's really just so much simpler to provide separate installers that it's really just not worth it to bundle them. You'll be doubling or tripling the installer size, which may just turn off some customers. If it's an internal tool, then there's really no downside - having the raw msi available allows so many more (remote) installing options.

So in short: yes, you can, but not with an MSI.



回答3:

I don't know enough about WiX to say for certain, but anecdotal evidence suggests this is not recommended. I'm reminded of all the downloads I see (MSDN and many others) where you must select between the 32-bit and 64-bit installer. Actually now that I think of it I've never seen nor heard of a "universal installer".



回答4:

You could try using the PROCESSOR_ARCHITECTURE environment variable in conditional tags for components to registry only what is needs to be registered for a specific architecture and this will apply when the MSI is run...not when it's built.

Example to detect 64 bit OS:

<Component Id="..." Guid="PUT-GUID-HERE">
  <Condition>NOT(%PROCESSOR_ARCHITECTURE = "x86")</Condition>
  ...
</Component>


Example to detect 32 bit OS:

<Component Id="..." Guid="PUT-GUID-HERE">
  <Condition>%PROCESSOR_ARCHITECTURE = "x86"</Condition>
  ...
</Component>


If you want to know more about referencing environment variables in MSI see this page: http://msdn.microsoft.com/en-us/library/windows/desktop/aa368012(v=vs.85).aspx#Access_Prefixes

For more information on what exactly PROCESSOR_ARCHITECTURE will return in which circumstances, see this page: https://superuser.com/q/396267/117857

However, as stated in the comments of this answer, this may not be truly what you're looking for. But I would think (not verified) that you could create a bootstrapper containing both 32 bit and 64 bit MSIs and then have the bootstrapper choose which MSI to apply at runtime dependent upon the OS architecture, though I haven't tried this and wouldn't know exactly how to do it, if I find out, I'll definitely post the answer.



标签: installer wix