App was initially delivered in 32 bit form. Now it is distributed with 32 and 64 bit version.
Now when user on 64 bit Windows upgrades application from 32 bit version to 64 bit version default installation folder should point to "Program files" (no x86).
I've updated my wsx
files in such way:
<?if $(var.Platform) = x64 ?>
<?define bitness = "(64 bit)" ?>
<?define Win64 = "yes" ?>
<?define PlatformProgramFilesFolder = "ProgramFiles64Folder" ?>
<?else ?>
<?define bitness = "(32 bit)" ?>
<?define Win64 = "no" ?>
<?define PlatformProgramFilesFolder = "ProgramFilesFolder" ?>
<?endif ?>
....
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="$(var.PlatformProgramFilesFolder)">
<Directory Name="COMPANY" Id="D.COMPANY">
<Directory Name="Product name" Id="APPDIR">
</Directory>
</Directory>
</Directory>
</Directory>
And this works nicely for fresh installs:
When 32 bit app is installed on 64 bit system it is installed in "Program files x86" and in all other cases installation is performed to "Program files".
In case of upgrade from 32 to 64 bit default destination folder is still "Program files x86" and I like that if it is moved to "Program files".
Is there a nice way to do it? Or do I have to override this some custom action in my C++ code?
Edit/Update:
Just to be clear. My application is a background service. Machine user doesn't see that application at all (except for extreme corner cases). In most of the time this service is installed/ungraded by other service which silently and remotely can install required software.
During this upgrade all 32 bit components are purged (one exe and couple dll-s) and replaced by 64 bit equivalents. Configuration data and cached data are transferred to upgraded application.
RemoveExistingProducts
is set to <RemoveExistingProducts After="InstallInitialize" />