Thursday, September 08, 2011

Creating MSI for x64 and x86 machines

For some time now I have been packaging for x64 and x86 machines, and have faced numerous issues while creating the MSI for x64 machines. Well MSI will mostly work in x86 because of less complexity of 32 bit machine. There always seems to be a problem when you try to install the application in 64 bit environment.

Registry Structure:

The Registries install differently in 32 and 64 bit machines. in 64 bit machines, there is a provision to install 32 bit applications registry and this goes in SysWOW64 folder.
By default all 32 bit installers install the registry in SysWOW64 hive. If you need to install the registries in normal mode as in directly in the registry as it was in 32 bit machines, then you need to change the Component in your MSI to 64 bit component. This will ensure that your registries are to be installed as 64 bit and not 32 bit.
You might face issue in compiling your 32 bit application with a 64 bit component. I would suggest you to compile your Application with 32 bit component and change the component attribute with ORCA later on.

Folder Structure:

I would like to share the 2 basic folders which are different in 64-bit machines.
Program Files: There are two folders for Program Files in 64 bit machines and they are Program Files and Program Files (x86). All applications which have 64 bit installer are installed in "Program Files" folder, whereas all 32 bit applications are by default installed in "Program Files (x86) folder.

System folder: The System 32 folder also behaves in the similar manner as Program Files and in this for 64 bit installers, the files which are to be placed in System 32 are directed to "System32" Folder only. The 32 bit installers however place these file in "SysWOW64" Folder.

Now the question comes to package the applications in such a way that we get desired output. I will list down certain scenarios and how to handle them in packaging. I hope to cover most as in whatever issues I have faced and your feedback for more scenarios is most welcome.
a) Scenario: In a capture application, files are getting installed in SysWOW64/Program Files (x86) folder when you want the files to be placed in System32/Program Files folder.
Resolution: You need to check the Summary section in your WISE Package Studio. If your package is marked as Intel,1033 (or Intel,xxxx), then you need to change this to x64,1033 (or x64,xxxx).
By doing this you are changing the installer type from 32 bit to 64 bit. You cannot install this package now on 32 bit machines and you will have to create a separate installer for that. I have done a lot of research and this only seems to be the most viable option as of now.
Also you need to change your directory in WISE package Studio/MSI.
There are additions of new already defined folders in MSI for 64 bit support. These folders are explained below:
[ProgramFiles64Folder] will redirect files to “Program Files" folder and [ProgramFilesFolder] will redirect the files to "Program Files (x86)" folder in 64 bit machines.
[System64Folder] will redirect files to "C:\Windows\System32" folder and [SystemFolder] will redirect the files to "C:\Windows\SysWOW64" folder in 64 bit machines.
Choose accordingly in your package. If there is still some problems, you can try making the components to be 64-Bit and try again.

b) Scenario: There is a vendor MSI which is 32 bit and install files to "Program Files (x86)" Folder in x64 machine. But due to the functionality of the application, you would require it to install to "Program Files" folder.
Resolution: If you are thinking that you will change the Summary section in MST file from Intel,1033 to x64,1033 and it will work, well you are thinking in right direction, but it does not work. You will have to change the summary section in MSI directly through ORCA and then do rest of the customizations in MST.
WIN64DUALFOLDERS determines what happens to the path variables while installation of an MSI. Based on the application type as in 64 bit or 32 bit, the paths are determined.
If it is a 64 bit installer then you will see something like this in the log file:

WIN64DUALFOLDERS: Substitution in 'C:\Program Files (x86)\ABC\XYZ\' folder had been blocked by the 1 mask argument (the folder pair's iSwapAttrib member = 0).
This means that the file system redirection will not happen. All paths will be defined as desired.

For example:
ProgramFilesFolder will be C:\Program Files (x86)
ProgramFiles64Folder will be C:\Program Files
and so on...

The end result would be as expected.
The 64-bit msiexec.exe is used in the whole process.

If it is a 32 bit installer then you will see something like this in the log file:

WIN64DUALFOLDERS: 'C:\Program Files (x86)\' will substitute 17 characters in 'C:\Program Files\' folder path. (mask argument = 0, the folder pair's iSwapAttrib member = 0).

This means:
ProgramFilesFolder will be C:\Program Files (x86)
ProgramFiles64Folder will become C:\Program Files (x86)


I hope this will help you in Packaging your applications for 64 bit.

2 comments:

Bhagwathraj Panchal said...

Yes, this is really helpfull to understand the basic challanges during migrating a package from 32 to 64-bit system.. Cheers

Anonymous said...

Yes. But the programmers of MSI haven' thought at the international Windows versions..

The international (link) paths of "c:\Program Files" are not redirected. E.g. if you do not use [ProgramFiles] directly, but create a [MyDir] property or so, you can directly write to the German named directory "c:\Programme" on a Windows 7 (with a German language setting (lang. pack). Of course, this directory is the same as "c:\Program Files" because it is mapped.
BTW: The people who "invented" this redirection made the install world unnecessarily double complicated. Wrong architecture this 64/32 separation. Without that redirection everything would work fine to make one MSI for 64 and 32 bit ! With my this special behaviour you have one idea how to circumvent.