From ccb0b8133c4450f9e6ef3bbfa71b4afe2f62d988 Mon Sep 17 00:00:00 2001 From: apacker1 Date: Fri, 22 Sep 2023 14:41:57 -0700 Subject: [PATCH] DotNetCompatibilityCheck: If running NetCoreCheck.exe fails with error code ERROR_EXE_MACHINE_TYPE_MISMATCH or ERROR_BAD_EXE_FORMAT then don't abort the installation, just set the property to 13. Fixes issue #7737 --- src/ext/NetFx/ca/netfxca.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/ext/NetFx/ca/netfxca.cpp b/src/ext/NetFx/ca/netfxca.cpp index 57eb96b16..06128f32e 100644 --- a/src/ext/NetFx/ca/netfxca.cpp +++ b/src/ext/NetFx/ca/netfxca.cpp @@ -977,12 +977,20 @@ extern "C" UINT __stdcall DotNetCompatibilityCheck( WcaLog(LOGMSG_VERBOSE, "Command: %ls %ls", pwzNetCoreCheckFilePath, pwzCommandLine); hr = ProcExec(pwzNetCoreCheckFilePath, pwzCommandLine, SW_HIDE, &hProcess); - ExitOnFailure(hr, "failed to run NetCoreCheck from binary '%ls' with command line: %ls %ls", pwzNetCoreCheckBinaryId, pwzNetCoreCheckFilePath, pwzCommandLine); + if (hr == HRESULT_FROM_WIN32(ERROR_EXE_MACHINE_TYPE_MISMATCH) || hr == HRESULT_FROM_WIN32(ERROR_BAD_EXE_FORMAT)) + { + dwExitCode = 13; + WcaLog(LOGMSG_VERBOSE, "NetCoreCheck executable for platform %ls is not compatible with current OS", pwzPlatform); + } + else + { + ExitOnFailure(hr, "failed to run NetCoreCheck from binary '%ls' with command line: %ls %ls", pwzNetCoreCheckBinaryId, pwzNetCoreCheckFilePath, pwzCommandLine); - hr = ProcWaitForCompletion(hProcess, INFINITE, &dwExitCode); - ExitOnFailure(hr, "failed to finish NetCoreCheck from binary '%ls' with command line: %ls %ls", pwzNetCoreCheckBinaryId, pwzNetCoreCheckFilePath, pwzCommandLine); - WcaLog(LOGMSG_VERBOSE, "Exit code: %lu", dwExitCode); - ReleaseHandle(hProcess); + hr = ProcWaitForCompletion(hProcess, INFINITE, &dwExitCode); + ExitOnFailure(hr, "failed to finish NetCoreCheck from binary '%ls' with command line: %ls %ls", pwzNetCoreCheckBinaryId, pwzNetCoreCheckFilePath, pwzCommandLine); + WcaLog(LOGMSG_VERBOSE, "Exit code: %lu", dwExitCode); + ReleaseHandle(hProcess); + } hr = WcaSetIntProperty(pwzProperty, dwExitCode); ExitOnFailure(hr, "failed to set NetCoreCheck result in %ls", pwzProperty);