Windows Develop Bookmark and Share   
 index > ClickOnce and Setup & Deployment Projects > How deploy an "Any CPU" application to either x86 or x64 platforms
 

How deploy an "Any CPU" application to either x86 or x64 platforms

I have an "Any CPU" application and the corresponding VS2008 setup projects has "TargetPlatform" that must be specified. Is there no concept of "Any CPU" in the installer? Am I supposed to duplicate each of my setup projects, one for x86 and one for x64? Is what is expected to be done if you want to natively support both x85 and x64 architectures?

Even when I set TargetPlatform to the x64 setting, the msi still wants to install to the Program Files x86 directory.

And no matter whether the setup project has x86 or x64 targets, Task Manager shows my app without the *32 suffix.

So two questions:

1. If the setup TargetPlatform is x86 and the app installed into the x86 directory, should an "Any CPU" app show the *32 suffix or not?

2. Why am I being installed into the x86 directory instead of installing into the regular Program Files directory?

Thanks, Dave
CodeSlinger  21 hours 54 minutes ago
Hi Dave,

To answer your questions:

1. If you .NET application is compiled as "Any CPU", then it will run as x64 on x64 OS and x86 on x86 OS, it doesn't matter where it is installed. The setup project settings will NOT affect this fact. So, on an x64 platform, an "Any CPU" app won't have the *32 suffix.

2. You need to create two MSI packages one for each platform. The "TargetPlatform" setting will affect the way Windows Installer treats folder variables, registries and GAC. To install files to 64-bit special folders, you should use corresponding folders like Common Files (64-bit), Program Files (64-bit), or System (64-bit). Please notice that the setup project will use [ProgramFiles64Folder] variable if the TargetPlatform of the setup project is x64; and [ProgramFilesFolder] for x86. I think that's why you got installed to Program Files (x86) on x64 OS.
 
A complete story of How to: Create a Windows Installer for a 64-bit Platform

Hope this helps.

Regards,
Jie
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg[at]microsoft.com

Please remember to mark the replies as answers if they help and unmark them if they provide no help.

If you have any feedback, please tell us.

The CodeFx Project
My Blog (in Simplified Chinese)
Wang, Jie  20 hours 49 minutes ago
Hi Dave,

To answer your questions:

1. If you .NET application is compiled as "Any CPU", then it will run as x64 on x64 OS and x86 on x86 OS, it doesn't matter where it is installed. The setup project settings will NOT affect this fact. So, on an x64 platform, an "Any CPU" app won't have the *32 suffix.

2. You need to create two MSI packages one for each platform. The "TargetPlatform" setting will affect the way Windows Installer treats folder variables, registries and GAC. To install files to 64-bit special folders, you should use corresponding folders like Common Files (64-bit), Program Files (64-bit), or System (64-bit). Please notice that the setup project will use [ProgramFiles64Folder] variable if the TargetPlatform of the setup project is x64; and [ProgramFilesFolder] for x86. I think that's why you got installed to Program Files (x86) on x64 OS.
 
A complete story of How to: Create a Windows Installer for a 64-bit Platform

Hope this helps.

Regards,
Jie
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg[at]microsoft.com

Please remember to mark the replies as answers if they help and unmark them if they provide no help.

If you have any feedback, please tell us.

The CodeFx Project
My Blog (in Simplified Chinese)
Wang, Jie  20 hours 49 minutes ago
Jie, thanks so much!

If I have a "Any CPU" application but use a 32 bit only assembly (e.g. Infragistics) will I be demoted to 32 bit or will some sort of "thunking" in the CLR happen?

Is there anything special about the msi itself in regards to what platform it targets? I could not find anything related to target platform in the Windows Installer doc. Do you know of any tool to convert a 64 bit msi to a 32 bit msi or vice versa? I hate to maintain 2 basically identical setup files for each of my applications when the only difference is essentially "TargetPlatform". Seems that ought to key the proper root Program Files rather than having to explicitly set it for 4 bit even though TargetPlatform is already set to that. If it just always used "Program Files" that would be the same for both platforms.

Thanks, Dave
CodeSlinger  12 hours 19 minutes ago
There's some detail here:
http://blogs.msdn.com/heaths/archive/2008/01/15/different-packages-are-required-for-different-processor-architectures.aspx 

but MSI doesn't have a switchable mode.  You don't need to make a separate install if a full 32-bit setup works - it will still install on x64. Make sure your binaries are all x86, and link to other x86 code, and you'll be fine, assuming your app doesn't do anything that requires access to the 64-bit view of the system.

In a 64-bit install the Program Files folder property name is ProgramFiles64Folder, so use that for your Application Folder (then you won't go to the ...(x86) folder).  Similarly, the common files folder is CommonFiles64Folder. That's what you'd use in a separate 64-bit setup.
Phil Wilson
PhilWilson  10 hours 59 minutes ago
I don't make registry entries in the msi file so 64/wow registry hive is not an issue and I WANT to always install in "C:\Program Files" as I want to be a 64 bit app on a 64 bit platform but obviously that need not always be on the C: drive.

So towards that goal, I tried setting the "Application Folder" to "%Program Files%" but the MSI fails as no one translates that. I also tried hard coding "C:\Program Files" and that was translated to the x86 directory anyway!

Seems MSFT could make setup projects more transparent for an "Any CPU" application because maintaining 2 separate setups is asking for trouble.

For "Any CPU" seems they could always use "Program Files" and the normal registry (never the wow6432 subtree) and always be correct.

Thanks! Dave
CodeSlinger  10 hours 5 minutes ago
I mentioned the ProgramFiles64Folder property, that's what you use!
Phil Wilson
PhilWilson  4 hours 32 minutes ago
Thanks Phil. I did understand that but if I use that special path then I have a setup I for sure cannot use on x86 and have to make a complete duplicate setup that has essentially no differences except the platform. All I was suggesting was that if MSFT did nothing special for 64 bit it would just work with "Any CPU" since the 64 bit developers went out of their way to make that transparent. I don't think the installer project should have translated my hard coding "Program Files" to the x86 version. I'm playing with Wix now as I think I can use the same wxs file for both x86 and x64 with a little parametrization. A bit of a learning curve though I'll have to admit. Thanks, Dave
CodeSlinger  4 hours 3 minutes ago

You can use google to search for other answers

Custom Search

More Threads

• Web deployment and Remoting
• Can't call Uninstall Override during Uninstall process
• Custom event logs, installation/creation and naming.
• how to read installation/publich path on run time
• Setup & Deployment Project - Cannot launch another installation
• Building the application package.
• Deployment Error
• WPF application publish.
• Large Size of Deployment for ClickOnce Applications
• ClickOnce Deploy, Works when debugged but not when deployed