Alex
Alex

Reputation: 7612

How can you access the TargetPlatform property in a Launch Condition?

I'm trying to access the TargetPlatform property value (which you can set in a Deployment project) from the condition within a "Launch Condition".

Basically I'm trying to tell the application not to install itself as a 32bit app if a 64bit version of Office is installed on that computer. Therefore I need to somehow get the application's bitness and put it in a launch condition.

I can get the bitness of Office from the registry, but I don't know how to access the TargetPlatform from the installer.

Thanks!

Upvotes: 1

Views: 2126

Answers (3)

batwad
batwad

Reputation: 3655

Add a custom action before the installation starts to perform the check. Use an Installer class to perform the custom action. You could use the OnBeforeInstall event to read the registry key and check the bitness as appropriate. Throwing an exception will cause the installation to abort, but there may be a cleaner way to do this.

Upvotes: 1

Liviu Mandras
Liviu Mandras

Reputation: 6617

Here are two link:

From the above link you can deduce that you can't target both platforms from a MSI installer. You will need to have two installers. Depending on how the installer is built, x86 or x64, will depend the way the installer interprets some constants that tell where to isntall the files - Program Files, or Program Files (x86).

You can't change the TargetPlatform of the installer at runtime.

What you can do maybe is to have two installers packed into a third one and based on the Office version installed that you say you can obtain run either sub-installer x86 or sub-installer x64, that will actually install the application files.

If MSI installer is not the outmost requirement I would go for NSIS. If not at least package the to MSI installers into an NSIS one. It is incredibly easy. NSIS is way cooler than MSI, talking from experience.

Upvotes: 2

Christopher Painter
Christopher Painter

Reputation: 55581

I've read this question a few times now and I'm not 100% certain I understand what you are trying to do. Do you have a 32bit application and you only want to install if they have 32bit Office (2010 I assume) installed? Do you also have a 64bit version that you want to install if 64bit office is installed?

I'm not sure why you need to care about the TargetPlatform property because if you know that 64bit Office is installed you must by definition be a 64bit OS. If 32bit Office is installed you could possibly be a 64bit OS but does it really matter? You said you cared about the bitness of Office not Windows.

I would think, from what I've read, that if you have an AppSearch that pulls the bitness into a property that you could just use a LaunchCondition that uses that property along with "or Installed" ( to handle being able to uninstall your application if Office was uninstalled first ) and be just fine.

Upvotes: 1

Related Questions