Reputation: 13
I'm new with Wix, let me give some info about what I'm trying to accomplish. I have an installer for software "B" but this software needs to have software "A" to actually work. So I want to add on the installer for software "B" to check if software "A" is installed, if it isn't then to show a message and then exit the installer.
So below is the code of what I have tried but the message always shows even though the file is there. So I'm basically looking for a file from software "A", if its present then the install should continue normally, if it isn't then the warning message should be displayed and exit installer.
<Property Id="SOFTWARE_A_INSTALLED">
<DirectorySearch
Id="LocationFile"
Path="C:\Windows\Microsoft.NET\assembly\SOFTWAREA">
<FileSearch Name="A.dll"></FileSearch>
</DirectorySearch>
</Property>
<Condition Message="[ProductName] requires SOFTWARE A installed.">
<![CDATA[Installed OR SOFTWARE_A_INSTALLED]]>
</Condition>
Thanks
Upvotes: 1
Views: 356
Reputation: 20790
There are usually much better ways of doing this. If that product is an MSI file then use an Upgrade element to detect the product's UpgradeCode, or use the Component ID of that assembly to do a component search. Or maybe the product creates a registry key that you can search for.
In general I don't recommend your approach because you said that your product B requires A for it to work. You didn't say that your INSTALL requires A for the install to succeed, so you are creating an install order dependency when there is actually only a product dependency. So what does your product do if A is uninstalled? Crash? Give any kind of warning? A better solution might be for your app to do the check rather then create a required install order.
If that assembly from A is really a dependency of your app and it is just one of a few files you depend on, then maybe it should be a redistributable, available as something such as a merge module. People don't (for example) check if Crystal Reports files are on the system - they just include the merge module that includes the files and installs them in a way that multiple users of a system can all share the same files. The same is true of many other shared files.
This vbscript will enumerate installed component ids to check that you have the right values for a component search:
Option Explicit
Public installer, fullmsg, comp, a, prod, fso, pname, ploc, pid, psorce
Set fso = CreateObject("Scripting.FileSystemObject")
Set a = fso.CreateTextFile("comps.txt", True)
' Connect to Windows Installer object
Set installer = CreateObject("WindowsInstaller.Installer")
a.writeline ("MSI Components")
on error resume next
For Each comp In installer.components
a.writeline (comp & " is used by the product:")
for each prod in Installer.ComponentClients (comp)
pid = installer.componentpath (prod, comp)
pname = installer.productinfo (prod, "InstalledProductName")
a.Writeline (" " & pname & " " & prod & "and is installed at " & pid)
Next
Next
Upvotes: 2