Burn bootstrapper is not detecting Windows installer version correctly
Asked Answered
C

4

6

Currently, I have the following fragment to check and install Windows Installer 4.5 if the user is on Windows XP.

<Fragment>
    <Property Id="WinXPx86HasInstaller">
      <![CDATA[VersionNT = 'v5.1' AND  VersionMsi >= "4.5.6001.22159"]]>
    </Property>

    <PackageGroup Id="Windows.Installer.4.5">
        <ExePackage Id="WinXp_x86"
                    Cache="no"
                    Compressed="no"
                    PerMachine="yes"
                    Permanent="yes"
                    Vital="yes"
                    InstallCommand="/norestart /passive"
                    SourceFile="WindowsXP-KB942288-v3-x86.exe"
                    DownloadUrl="http://download.microsoft.com/download/2/6/1/261fca42-22c0-4f91-9451-0e0f2e08356d/WindowsXP-KB942288-v3-x86.exe"
                    DetectCondition="WinXPx86HasInstaller"
                    InstallCondition="NOT WinXPx86HasInstaller">
            <ExitCode Behavior="forceReboot" />
        </ExePackage>
    </PackageGroup>
</Fragment>

However, this is not working and the property "WinXPx86HasInstaller" always evaluates to false even when it is installed.

What am I doing wrong?

Cornetcy answered 14/5, 2012 at 16:58 Comment(0)
C
14

It's somewhat annoying that, unlike WiX, there's no way to easily test Burn InstallConditions - only DetectConditions are printed out in the log at runtime. After spending a while to test inverted InstallConditions as DetectConditions [*], this fragment appears to work for me:

<!-- Windows Installer 4.5 -->
<Fragment>
    <PackageGroup Id="WindowsInstaller45">
        <ExePackage
            Cache="no"
            Compressed="no"
            PerMachine="yes"
            Permanent="yes"
            Vital="yes"
            SourceFile="redist\WindowsXP-KB942288-v3-x86.exe"
            DownloadUrl="http://download.microsoft.com/download/2/6/1/261fca42-22c0-4f91-9451-0e0f2e08356d/WindowsXP-KB942288-v3-x86.exe"
            InstallCondition="VersionNT=v5.1 AND NOT VersionNT64 AND VersionMsi &lt; v4.5"
            InstallCommand="/quiet /norestart">
            <ExitCode Behavior="forceReboot"/>
        </ExePackage>
        <ExePackage
            Cache="no"
            Compressed="no"
            PerMachine="yes"
            Permanent="yes"
            Vital="yes"
            SourceFile="redist\WindowsServer2003-KB942288-v4-x86.exe"
            DownloadUrl="http://download.microsoft.com/download/2/6/1/261fca42-22c0-4f91-9451-0e0f2e08356d/WindowsServer2003-KB942288-v4-x86.exe"
            InstallCondition="VersionNT=v5.2 AND NOT VersionNT64 AND VersionMsi &lt; v4.5"
            InstallCommand="/quiet /norestart">
            <ExitCode Behavior="forceReboot"/>
        </ExePackage>
        <ExePackage
            Cache="no"
            Compressed="no"
            PerMachine="yes"
            Permanent="yes"
            Vital="yes"
            SourceFile="redist\WindowsServer2003-KB942288-v4-x64.exe"
            DownloadUrl="http://download.microsoft.com/download/2/6/1/261fca42-22c0-4f91-9451-0e0f2e08356d/WindowsServer2003-KB942288-v4-x64.exe"
            InstallCondition="VersionNT=v5.2 AND VersionNT64 AND VersionMsi &lt; v4.5"
            InstallCommand="/quiet /norestart">
            <ExitCode Behavior="forceReboot"/>
        </ExePackage>
        <MsuPackage
            Cache="no"
            Compressed="no"
            Permanent="yes"
            Vital="yes"
            KB="KB942288"
            SourceFile="redist\Windows6.0-KB942288-v2-x86.msu"
            DownloadUrl="http://download.microsoft.com/download/2/6/1/261fca42-22c0-4f91-9451-0e0f2e08356d/Windows6.0-KB942288-v2-x86.msu"
            InstallCondition="VersionNT=v6.0 AND NOT VersionNT64 AND VersionMsi &lt; v4.5"/>
        <MsuPackage
            Cache="no"
            Compressed="no"
            Permanent="yes"
            Vital="yes"
            KB="KB942288"
            SourceFile="redist\Windows6.0-KB942288-v2-x64.msu"
            DownloadUrl="http://download.microsoft.com/download/2/6/1/261fca42-22c0-4f91-9451-0e0f2e08356d/Windows6.0-KB942288-v2-x64.msu"
            InstallCondition="VersionNT=v6.0 AND VersionNT64 AND VersionMsi &lt; v4.5"/>
    </PackageGroup>
</Fragment>
Canyon answered 18/5, 2012 at 7:24 Comment(3)
Awesome that's works perfectly. Thanks a lot. Thanks for the other platforms too, I hadn't got round to doing those yet! ;)Cornetcy
I think the install condition should be changed to "(VersionNT=v5.2 OR VersionNT=v5.1) AND VersionNT64 AND VersionMsi &lt; v4.5" on the Server 2003 x64 ExePackage. From link, For Windows Server 2003 Service Pack 1, Windows Server 2003 Service Pack 2 and Windows XP 64-bit Editions: x64 Platform: WindowsServer2003-KB942288-v4-x64.exe.Epicycle
@Epicycle There was only ever a 32-bit version of NT 5.1: 64-bit XP and 2003 were 5.2 - see msdn.microsoft.com/en-gb/library/windows/desktop/… .Venator
E
5

For what it's worth, I believe the original reason as to why your detection was failing would be because VersionMsi only has two digits of precision:

<![CDATA[VersionNT = 'v5.1' AND  VersionMsi >= "4.5.6001.22159"]]>

should have been

<![CDATA[VersionNT = 'v5.1' AND  VersionMsi >= v4.5]]>

I had recently struggled with a similar issue and ended up digging into Burn to find the answer.

static HRESULT InitializeVariableVersionMsi(
__in DWORD_PTR dwpData,
__inout BURN_VARIANT* pValue
)
{
    UNREFERENCED_PARAMETER(dwpData);

    HRESULT hr = S_OK;
    DLLGETVERSIONPROC pfnMsiDllGetVersion = NULL;
    DLLVERSIONINFO msiVersionInfo = { };

    // Get DllGetVersion proc address
    pfnMsiDllGetVersion = (DLLGETVERSIONPROC)::GetProcAddress(::GetModuleHandleW(L"msi"), "DllGetVersion");
    ExitOnNullWithLastError(pfnMsiDllGetVersion, hr, "Failed to find DllGetVersion entry point in msi.dll.");

    // Get msi.dll version information
    msiVersionInfo.cbSize = sizeof(DLLVERSIONINFO);
    hr = pfnMsiDllGetVersion(&msiVersionInfo);
    ExitOnFailure(hr, "Failed to get msi.dll version info.");

    hr = BVariantSetVersion(pValue, MAKEQWORDVERSION(msiVersionInfo.dwMajorVersion, msiVersionInfo.dwMinorVersion, 0, 0));
    ExitOnFailure(hr, "Failed to set variant value.");

    LExit:
    return hr;
}
Epicycle answered 14/9, 2012 at 17:5 Comment(0)
B
0

Try to use

DetectCondition="VersionMsi >= v4.5 AND VersionNT = 501 AND NOT VersionNT64"

And I think, InstallCondition is not necessary in this case.

Bev answered 17/5, 2012 at 9:39 Comment(0)
R
-1

Version NT has values 501, 502, 600, etc. The value is an integer: MajorVersion * 100 + MinorVersion. Use '501' instead of 'v5.1'.

Source: http://msdn.microsoft.com/en-us/library/windows/desktop/aa372495%28v=vs.85%29.aspx

Rusel answered 15/5, 2012 at 13:32 Comment(6)
Not according to the Burn documentation, wix.sourceforge.net/manual-wix3/bundle_built_in_variables.htm. I have checked the burn sourcecode and as far as I can see the docs above are correct (C++ is very rusty). I actually had 501 in my original code before I noticed the discrepancy and it didn't work then either.Cornetcy
VersionNT is both a Burn variable and an MSI property. In this case, I think it will be treated as an MSI property.Rusel
Why do you think that? The code above is within the Burn bootstrapper not an msi. In any case I've tried both and neither work. :(Cornetcy
I haven't worked much with CDATA conditions (they seem just weird to me :-/ ), but I think the condition here should be: <![CDATA[VersionNT <> 501 OR VersionMsi < "4.5.6001.22159"]]>.Rusel
A cleaner approach here would be using the condition directly in DetectCondition as in: DetectCondition="VersionNT=501 AND VersionMsi &gt;= "4.5.6001.22159"". Also, DetectCondition alone is sufficient for determining if the package will be installed. You don't need the InstallCondition attribute.Rusel
You were indeed correct, @caveman_dick, it's supposed to be in v#.# format. Looks like Burn uses a different parser for version strings rather than Windows Installer.Canyon

© 2022 - 2024 — McMap. All rights reserved.