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?

4

4 回答 4

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>
于 2012-05-18T07:24:50.460 回答
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;
}
于 2012-09-14T17:05:40.880 回答
0

Try to use

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

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

于 2012-05-17T09:39:18.770 回答
-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

于 2012-05-15T13:32:45.400 回答