wixwindows-installerwix3.10

WiX Error Determining Previous Package Version


Running into an issue with version numbers.

We used to use Installshield for our client installer. Since switching to WiX, we've "fixed" a few things such as the version numbering scheme. We used to use x.x.x-y, but WiX does not allow the "-" to be part of the version #.

When I try to update an older installed product using the "dashed" version #, the installation stops (before it even gets going) with:

[09A4:1908][2016-09-20T09:20:34]e000: Error 0x80070057: Failed to convert version: 5.3.0-7 to DWORD64 for ProductCode: {...}
[09A4:1908][2016-09-20T09:20:34]e151: Detect failed for package: Client_MSI, error: 0x80070057

The error appears to cause the engine to not trigger OnDetectMsiFeature, however, the engine does appear to know, somehow, about the features:

[09A4:1908][2016-09-20T09:20:34]i000: WixWPF: Enter Method: OnDetectPackageComplete
[09A4:1908][2016-09-20T09:20:34]i000: WixWPF: Leaving Method: OnDetectPackageComplete
[09A4:1908][2016-09-20T09:20:34]i101: Detected package: NetFx40Web, state: Present, cached: None
[09A4:1908][2016-09-20T09:20:34]i101: Detected package: vcredist2015x64, state: Present, cached: Complete
[09A4:1908][2016-09-20T09:20:34]i101: Detected package: vcredist2015x86, state: Present, cached: None
[09A4:1908][2016-09-20T09:20:34]i101: Detected package: Client_MSI, state: Unknown, cached: None
[09A4:1908][2016-09-20T09:20:34]i104: Detected package: Client_MSI, feature: FeatureA, state: Unknown
[09A4:1908][2016-09-20T09:20:34]i104: Detected package: Client_MSI, feature: FeatureB, state: Unknown
...
[09A4:1908][2016-09-20T09:20:34]i000: WixWPF: Enter Method: OnDetectComplete

UPDATE:

I tracked the problem with the version numbers to dutil\fileutil.cpp. I changed the check on line 444 to:

while (wzPartEnd < wzEnd && ((L'.' != *wzPartEnd)
                         &&  (L'-' != *wzPartEnd)))

soas to accept the '-' as a version separator. Now, the new bootstrapper loads, but is having problems with state detection. While it "sees" the package and features, it "sees" all of them as "Absent".

[0280:1050][2016-09-20T12:36:05]i103: Detected related package: {...}, scope: PerMachine, version: 5.3.0.7, language: 0 operation: MajorUpgrade
[0280:1050][2016-09-20T12:36:05]i000: WixWPF: Enter Method: OnDetectRelatedMsiPackage
[0280:1050][2016-09-20T12:36:05]i000: WixWPF: Leaving Method: OnDetectRelatedMsiPackage
[0280:1050][2016-09-20T12:36:05]i000: WixWPF: Enter Method: OnDetectMsiFeature
[0280:1050][2016-09-20T12:40:42]i000: WixWPF: Leaving Method: OnDetectMsiFeature
...
[0280:1050][2016-09-20T12:41:04]i000: WixWPF: Enter Method: OnDetectPackageComplete
[0280:1050][2016-09-20T12:41:07]i000: WixWPF: Leaving Method: OnDetectPackageComplete
[0280:1050][2016-09-20T12:41:07]i101: Detected package: NetFx40Web, state: Present, cached: None
[0280:1050][2016-09-20T12:41:07]i101: Detected package: vcredist2015x64, state: Present, cached: Complete
[0280:1050][2016-09-20T12:41:07]i101: Detected package: vcredist2015x86, state: Present, cached: None
[0280:1050][2016-09-20T12:41:07]i101: Detected package: Client_MSI, state: Absent, cached: None
[0280:1050][2016-09-20T12:41:07]i104: Detected package: Client_MSI, feature: LunaClient, state: Absent
[0280:1050][2016-09-20T12:41:07]i104: Detected package: Client_MSI, feature: FeatureB, state: Absent

So, my new questions are:

  1. Why is the old package and selected list of features all marked as Absent?
  2. Can I recover from this?

Solution

  • Updating this a month after I got it working. I found that I needed to hook another event, DetectRelatedMsiPackage. I found this issue and associated code, which the poster was kind enough to share and which I was able to adapt to my needs, as follows:

    public override void OnDetectRelatedMsiPackage(WPFBootstrapperEventArgs<Wix.DetectRelatedMsiPackageEventArgs> e)
    {
        var existingPackageProductCode = e.Arguments.ProductCode;
        var existingPackageId = e.Arguments.PackageId;
    
        if (existingPackageId != HSMClientPackageID)
        {
            return;
        }
    
        InstallData.RelatedOperation = e.Arguments.Operation;
        if (InstallData.RelatedOperation == Wix.RelatedOperation.MajorUpgrade)
        {
            //requires reference to WiX Toolset\SDK\Microsoft.Deployment.WindowsInstaller.dll
            var installedPackage = new ProductInstallation(existingPackageProductCode);
            if (!installedPackage.IsInstalled)
            {
                //Log(string.Format("Migrating Package {0}, which is not installed, so marking it and it's features as Absent", existingPackageId));
                _packageStates[existingPackageId] = Wix.PackageState.Absent;
            }
            else
            {
                //Log(string.Format("Migrating features for MajorUpgrade of Package {0}", existingPackageId));
    
                _packageStates[existingPackageId] = Wix.PackageState.Present;
    
                foreach (var currentInstallFeature in installedPackage.Features)
                {
                    switch (currentInstallFeature.State)
                    {
                        case InstallState.Local:
                            //Log(string.Format("Migrating feature {1} of Package {0} - marking as Present", existingPackageId, currentInstallFeature.FeatureName));
                            _featureStates[currentInstallFeature.FeatureName] = Wix.FeatureState.Local;
                            break;
                        case InstallState.Absent:
                            //Log(string.Format("Migrating feature {1} of Package {0} - marking as Absent", existingPackageId, currentInstallFeature.FeatureName));
                            _featureStates[currentInstallFeature.FeatureName] = Wix.FeatureState.Absent;
                            break;
                        default:
                            //Log(string.Format("Migrating feature {1} of Package {0} - marking as Unknown", existingPackageId, currentInstallFeature.FeatureName));
                            _featureStates[currentInstallFeature.FeatureName] = Wix.FeatureState.Unknown;
                            break;
                    }
                }
            }
        }
    }