How to check for installed package in WiX 3.0?
Asked Answered
B

3

6

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 ?

Bookerbookie answered 12/5, 2009 at 8:7 Comment(0)
B
3

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>
Bookerbookie answered 13/5, 2009 at 12:58 Comment(2)
+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: blogs.msdn.com/oldnewthing/archive/2003/11/03/55532.aspxBracket
A 100% supported solution without custom actions has been suggested here : 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.Bookerbookie
M
3

You can use Upgrade table

<Upgrade Id="36E76465-5548-390F-955A-2776582C6A6C">
  <UpgradeVersion OnlyDetect="yes" Property="TFSCLIENT" Minimum="11.0.50727" />
</Upgrade>
<Condition Message="ERROR: Team Explorer for Microsoft Visual Studio 2012 is not installed">
  Installed OR TFSCLIENT
</Condition>

Now the tricky bit is to find Upgrade Code (specified in Id attribute above). If you have an MSI package, just look at it by Orca. If you don't - try this solution.

Mulligan answered 29/10, 2013 at 16:52 Comment(0)
B
1

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.

Bracket answered 13/5, 2009 at 0:20 Comment(1)
Interesting, but I don't think I'll have the time to delve into custom actions. For now.Bookerbookie

© 2022 - 2024 — McMap. All rights reserved.