Given:
- Wix 3.0 is used to create MSI.
- The product consists of multiple feature.
- Each feature has few sub features. It’s a standard MSI feature tree.
- Each feature or sub feature depend on multiple external components. E.g. .NET 4, ASP.NET etc
- Custom action written in C# using Wix 3.0 SDK processes these dependency and evaluates if components are present or not for a given set of features.
- At time of install if dependent component is missing for given selection of features, installation fails.
To achieve: Ability to execute prerequisite check, which is already done in MSI as custom action during installation, without installing MSI on a given machine.
Failed Attempts:
1) Custom action have function signature like this
[CustomAction]
public static ActionResult ProcessFeaturePrerequisite(Session session);
In order to get session object I used following API present in Wix 3.0 SDK
Session session = Installer.OpenPackage("Pathto\\Product.msi", true); // true doesn’t install it. Also tried with false, but didn’t work.
When I invoke the above method with above session following things fail.
session.Features["SomeFeature"].CurrentState;
This throws exception.
System.ArgumentException was unhandled by user code
Message=Feature ID not registered. SomeFeature
Source=Microsoft.Deployment.WindowsInstaller
StackTrace:
at Microsoft.Deployment.WindowsInstaller.FeatureInfo.get_CurrentState()
Also below critical API which determines prerequisite status always returns false.
session.EvaluateCondition(prereq);
2) I know a command line way to specify features to the above MSI and install it. It goes like this
msiexec /i "Product.msi" ADDLOCAL=ALL REMOVE="Foo,Bar "
I couldn’t find any API in SDK which allows me to pass additional params which returns session object without starting installation. My guess is passing such param will make session.Features more valid.
Questions: So how do I achieve above goal? Is there
- any API in Wix SDK which allows me to call custom action without invoking installation?
- any way to invoke custom action from command line for a given MSI without installing?
- any way to make Wix to change MSI into accepting a command string containing custom action name which only evaluates the action?
- any better way to do the same?