刻录引导程序未正确检测Windows安装程序版本

时间:2012-05-14 16:58:34

标签: wix wix3.6 burn

目前,如果用户在Windows XP上,我有以下片段来检查和安装Windows Installer 4.5。

<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>

但是,这不起作用,即使安装它,属性“WinXPx86HasInstaller”也总是计算为false。

我做错了什么?

4 个答案:

答案 0 :(得分:14)

有点烦人的是,与WiX不同,没有办法轻松测试Burn InstallConditions - 只有DetectConditions在运行时打印在日志中。花了一段时间测试倒置 InstallConditions作为DetectConditions [*],这个片段似乎对我有用:

<!-- 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>

答案 1 :(得分:4)

对于它的价值,我相信原因是你的检测失败的原因是因为VersionMsi只有两位数的精度:

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

应该是

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

我最近遇到了类似的问题,最后挖掘Burn来找到答案。

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;
}

答案 2 :(得分:0)

尝试使用

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

我认为,在这种情况下,InstallCondition不是必需的。

答案 3 :(得分:-1)

版本NT的值为501,502,600等。值为整数:MajorVersion * 100 + MinorVersion。使用'501'代替'v5.1'。

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

相关问题