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

cav*_*ick 6 wix burn wix3.6

目前,如果用户在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>
Run Code Online (Sandbox Code Playgroud)

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

我究竟做错了什么?

Jer*_*ong 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>
Run Code Online (Sandbox Code Playgroud)


jch*_*ver 5

就其价值而言,我相信您的检测失败的最初原因是因为 VersionMsi 只有两位精度:

<![CDATA[VersionNT = 'v5.1' AND  VersionMsi >= "4.5.6001.22159"]]>
Run Code Online (Sandbox Code Playgroud)

本来应该

<![CDATA[VersionNT = 'v5.1' AND  VersionMsi >= v4.5]]>
Run Code Online (Sandbox Code Playgroud)

我最近在一个类似的问题上挣扎,最终深入研究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;
}
Run Code Online (Sandbox Code Playgroud)