tags:

views:

718

answers:

2

I'd like to check that Crystal Reports Basic for Visual Studio 2008 is installed as a condition for my own installation package.

I found this in the bootstrapper description for this product (C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\CrystalReports10_5\product.xml) :

<InstallChecks>
  <MsiProductCheck Property="CRVSInstalled" Product="{AA467959-A1D6-4F45-90CD-11DC57733F32}"/>
  <MsiProductCheck Property="CRVSRunTimex86Installed" Product="{CE26F10F-C80F-4377-908B-1B7882AE2CE3}"/>
  <MsiProductCheck Property="CRVSRunTimex64Installed" Product="{2BFA9B05-7418-4EDE-A6FC-620427BAAAA3}. "/>
</InstallChecks>

Trying to mimic this behavior in WiX, I did the following :

<Property Id="CRVSINSTALLED">
  <ComponentSearch Id="CRVSInstalledSearch" Guid="{AA467959-A1D6-4F45-90CD-11DC57733F32}" />
</Property>
<Property Id="CRVSRUNTIMEX86INSTALLED">
  <ComponentSearch Id="CRVSRunTimex86InstalledSearch" Guid="{CE26F10F-C80F-4377-908B-1B7882AE2CE3}" />
</Property>
<Property Id="CRVSRUNTIMEX64INSTALLED">
  <ComponentSearch Id="CRVSRunTimex64InstalledSearch" Guid="{2BFA9B05-7418-4EDE-A6FC-620427BAAAA3}" />
</Property>
<Condition Message="!(loc.CrystalReportsRequired)">Installed OR CRVSINSTALLED OR CRVSRUNTIMEX86INSTALLED OR CRVSRUNTIMEX64INSTALLED</Condition>

But it seems that ComponentSearch is looking for package components (files, directories) that have their own ids, rather than looking for the package itself.

So how can I do this ?

+1  A: 

The windows installer API has the MsiQueryProductState function in msi.dll to do this. Unfortunately you'll have to write a custom action to make use of this in your installer. The assemblies in C:\Program Files\Windows Installer XML v3\SDK may make this easier.

Wim Coenen
Interesting, but I don't think I'll have the time to delve into custom actions. For now.
Mac
+2  A: 

As suggested here :

Try a registry search under HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\{productcode}. Also consider a search under HKCU if both your product and the dependency are per-user products.

This goes like this :

<Property Id="CRVSINSTALLED">
  <RegistrySearch Id="CRVSInstalledSearch" Root="HKLM" Key="Software\Microsoft\Windows\CurrentVersion\Uninstall\{AA467959-A1D6-4F45-90CD-11DC57733F32}" Name="InstallDate" Type="raw" />
</Property>
<Property Id="CRVSRUNTIMEINSTALLED">
  <RegistrySearch Id="CRVSRunTimeInstalledSearch" Root="HKLM" Key="Software\Microsoft\Windows\CurrentVersion\Uninstall\{CE26F10F-C80F-4377-908B-1B7882AE2CE3}" Name="InstallDate" Type="raw" />
</Property>
<Property Id="CRVSRUNTIMEINSTALLED">
  <RegistrySearch Id="CRVSRunTimeInstalledSearch" Root="HKLM" Key="Software\Microsoft\Windows\CurrentVersion\Uninstall\{2BFA9B05-7418-4EDE-A6FC-620427BAAAA3}" Name="InstallDate" Type="raw" />
</Property>
Mac
+1 for avoiding custom actions but beware: AFAIK this is undocumented and therefore in principle unsupported. The following post by Raymond Chen comes to mind: http://blogs.msdn.com/oldnewthing/archive/2003/11/03/55532.aspx
Wim Coenen
Thanks for pointing this out.
Mac
A 100% supported solution without custom actions has been suggested here : http://article.gmane.org/gmane.comp.windows.devel.wix.user/38263 But I don't have time to test it right now, and I would need the upgrade GUID for CR, which I don't know yet how to retrieve.
Mac