From 19c52f14644ac666c12f1a44bc2c0cce1586b8c5 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Sun, 22 Aug 2021 22:26:23 -0400 Subject: On SuppressDowngradeFailure, quit after detect. Implements https://github.com/wixtoolset/issues/issues/6537. --- src/ext/Bal/Bal.wixext.sln | 2 +- .../WixStandardBootstrapperApplication.cpp | 67 +++++++++------------- .../burn/TestData/WixStdBaTests/BundleA/Bundle.wxs | 17 ++++++ .../TestData/WixStdBaTests/BundleA/BundleA.wxs | 10 ++++ .../WixStdBaTests/BundleA/BundleA_v11.wixproj | 15 +++++ .../WixStdBaTests/BundleA/BundleA_v12.wixproj | 15 +++++ .../WixStdBaTests/PackageA/PackageA.wixproj | 9 +++ 7 files changed, 95 insertions(+), 40 deletions(-) create mode 100644 src/test/burn/TestData/WixStdBaTests/BundleA/Bundle.wxs create mode 100644 src/test/burn/TestData/WixStdBaTests/BundleA/BundleA.wxs create mode 100644 src/test/burn/TestData/WixStdBaTests/BundleA/BundleA_v11.wixproj create mode 100644 src/test/burn/TestData/WixStdBaTests/BundleA/BundleA_v12.wixproj create mode 100644 src/test/burn/TestData/WixStdBaTests/PackageA/PackageA.wixproj (limited to 'src') diff --git a/src/ext/Bal/Bal.wixext.sln b/src/ext/Bal/Bal.wixext.sln index ddf9ef88..ee14dd97 100644 --- a/src/ext/Bal/Bal.wixext.sln +++ b/src/ext/Bal/Bal.wixext.sln @@ -17,7 +17,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolset.Bal.wixext", "wi EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolset.Dnc.Host", "WixToolset.Dnc.Host\WixToolset.Dnc.Host.csproj", "{0D780900-C2FF-4FA2-8CB5-8A19768724C5}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WixToolset.Mba.Host", "WixToolset.Mba.Host\WixToolset.Mba.Host.csproj", "{F2BA1935-70FA-4156-B161-FD03850B4FAA}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolset.Mba.Host", "WixToolset.Mba.Host\WixToolset.Mba.Host.csproj", "{F2BA1935-70FA-4156-B161-FD03850B4FAA}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.FullFramework2MBA", "test\examples\FullFramework2MBA\Example.FullFramework2MBA.csproj", "{CC4236FC-226E-4232-AB50-24CBEC4D314D}" EndProject diff --git a/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp b/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp index be2dde1f..74e0b7d3 100644 --- a/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp +++ b/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp @@ -286,6 +286,7 @@ public: // IBootstrapperApplication // If we're not doing a prerequisite install, remember when our bundle would cause a downgrade. if (!m_fPrereq && BOOTSTRAPPER_RELATED_OPERATION_DOWNGRADE == operation) { + BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "A newer version (v%ls) of this product is installed.", wzVersion); m_fDowngrading = TRUE; } } @@ -321,12 +322,14 @@ public: // IBootstrapperApplication ) { HRESULT hr = S_OK; + // If we're not interacting with the user or we're doing a layout or we're resuming just after a force restart // then automatically start planning. BOOL fSkipToPlan = SUCCEEDED(hrStatus) && (BOOTSTRAPPER_DISPLAY_FULL > m_command.display || BOOTSTRAPPER_ACTION_LAYOUT == m_command.action || BOOTSTRAPPER_RESUME_TYPE_REBOOT == m_command.resumeType); + // If we're requiring user input (which currently means Install, Repair, or Uninstall) // or if we're skipping to an action that modifies machine state // then evaluate conditions. @@ -360,6 +363,23 @@ public: // IBootstrapperApplication } } } + else if (m_fDowngrading && BOOTSTRAPPER_ACTION_UNINSTALL < m_command.action) + { + if (m_fSuppressDowngradeFailure) + { + BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Downgrade failure has been suppressed; exiting bundle."); + + hr = S_OK; + SetState(WIXSTDBA_STATE_APPLIED, hr); + ExitFunction(); + } + else + { + // If we are going to apply a downgrade, bail. + hr = HRESULT_FROM_WIN32(ERROR_PRODUCT_VERSION); + BalExitOnFailure(hr, "Cannot install a product when a newer version is installed."); + } + } } SetState(WIXSTDBA_STATE_DETECTED, hrStatus); @@ -369,6 +389,7 @@ public: // IBootstrapperApplication ::PostMessageW(m_hWnd, WM_WIXSTDBA_PLAN_PACKAGES, 0, m_command.action); } + LExit: return hr; } @@ -2162,7 +2183,7 @@ private: { HRESULT hr = S_OK; LPWSTR sczModulePath = NULL; - IXMLDOMDocument *pixdManifest = NULL; + IXMLDOMDocument* pixdManifest = NULL; hr = BalManifestLoad(m_hModule, &pixdManifest); BalExitOnFailure(hr, "Failed to load bootstrapper application manifest."); @@ -2789,21 +2810,21 @@ private: switch (uMsg) { case WM_NCCREATE: - { + { LPCREATESTRUCT lpcs = reinterpret_cast(lParam); pBA = reinterpret_cast(lpcs->lpCreateParams); #pragma warning(suppress:4244) ::SetWindowLongPtrW(hWnd, GWLP_USERDATA, reinterpret_cast(pBA)); - } - break; + } + break; case WM_NCDESTROY: - { + { LRESULT lres = CallDefaultWndProc(pBA, hWnd, uMsg, wParam, lParam); ::SetWindowLongPtrW(hWnd, GWLP_USERDATA, 0); ::PostQuitMessage(0); return lres; - } + } case WM_CREATE: if (!pBA->OnCreate(hWnd)) @@ -3023,8 +3044,6 @@ private: } m_pEngine->CloseSplashScreen(); - - return; } @@ -3042,8 +3061,6 @@ private: } m_pEngine->CloseSplashScreen(); - - return; } @@ -3073,8 +3090,6 @@ private: { SetState(WIXSTDBA_STATE_DETECTING, hr); } - - return; } @@ -3089,20 +3104,6 @@ private: m_plannedAction = action; - // If we are going to apply a downgrade, bail. - if (m_fDowngrading && BOOTSTRAPPER_ACTION_UNINSTALL < action) - { - if (m_fSuppressDowngradeFailure) - { - BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "A newer version of this product is installed but downgrade failure has been suppressed; continuing..."); - } - else - { - hr = HRESULT_FROM_WIN32(ERROR_PRODUCT_VERSION); - BalExitOnFailure(hr, "Cannot install a product when a newer version is installed."); - } - } - SetState(WIXSTDBA_STATE_PLANNING, hr); hr = m_pEngine->Plan(action); @@ -3113,8 +3114,6 @@ private: { SetState(WIXSTDBA_STATE_PLANNING, hr); } - - return; } @@ -3139,8 +3138,6 @@ private: { SetState(WIXSTDBA_STATE_APPLYING, hr); } - - return; } @@ -3490,8 +3487,6 @@ private: ReleaseStr(sczLicenseUrl); ReleaseStr(sczLicenseDirectory); ReleaseStr(sczLicenseFilename); - - return; } @@ -3579,8 +3574,6 @@ private: ReleaseStr(sczLaunchTargetElevatedId); StrSecureZeroFreeString(sczLaunchTarget); ReleaseStr(sczUnformattedLaunchTarget); - - return; } @@ -3593,8 +3586,6 @@ private: m_fAllowRestart = TRUE; ::SendMessageW(m_hWnd, WM_CLOSE, 0, 0); - - return; } @@ -3614,8 +3605,6 @@ private: LExit: ReleaseStr(sczLogFile); - - return; } @@ -3902,7 +3891,7 @@ public: __in BOOL fPrereq, __in HRESULT hrHostInitialization, __in IBootstrapperEngine* pEngine - ) : CBalBaseBootstrapperApplication(pEngine, 3, 3000) + ) : CBalBaseBootstrapperApplication(pEngine, 3, 3000) { m_hModule = hModule; m_command = { }; diff --git a/src/test/burn/TestData/WixStdBaTests/BundleA/Bundle.wxs b/src/test/burn/TestData/WixStdBaTests/BundleA/Bundle.wxs new file mode 100644 index 00000000..dded1f40 --- /dev/null +++ b/src/test/burn/TestData/WixStdBaTests/BundleA/Bundle.wxs @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/src/test/burn/TestData/WixStdBaTests/BundleA/BundleA.wxs b/src/test/burn/TestData/WixStdBaTests/BundleA/BundleA.wxs new file mode 100644 index 00000000..b3345b5d --- /dev/null +++ b/src/test/burn/TestData/WixStdBaTests/BundleA/BundleA.wxs @@ -0,0 +1,10 @@ + + + + + + + + + diff --git a/src/test/burn/TestData/WixStdBaTests/BundleA/BundleA_v11.wixproj b/src/test/burn/TestData/WixStdBaTests/BundleA/BundleA_v11.wixproj new file mode 100644 index 00000000..5fa77495 --- /dev/null +++ b/src/test/burn/TestData/WixStdBaTests/BundleA/BundleA_v11.wixproj @@ -0,0 +1,15 @@ + + + + Bundle + {7D977157-06C9-4176-A931-AC16E18AAB51} + $(DefineConstants);Version=1.1 + WixStdBaTest1_v11 + + + + + + + + \ No newline at end of file diff --git a/src/test/burn/TestData/WixStdBaTests/BundleA/BundleA_v12.wixproj b/src/test/burn/TestData/WixStdBaTests/BundleA/BundleA_v12.wixproj new file mode 100644 index 00000000..5918df51 --- /dev/null +++ b/src/test/burn/TestData/WixStdBaTests/BundleA/BundleA_v12.wixproj @@ -0,0 +1,15 @@ + + + + Bundle + {7D977157-06C9-4176-A931-AC16E18AAB51} + $(DefineConstants);Version=1.2 + WixStdBaTest1_v12 + + + + + + + + \ No newline at end of file diff --git a/src/test/burn/TestData/WixStdBaTests/PackageA/PackageA.wixproj b/src/test/burn/TestData/WixStdBaTests/PackageA/PackageA.wixproj new file mode 100644 index 00000000..a028c152 --- /dev/null +++ b/src/test/burn/TestData/WixStdBaTests/PackageA/PackageA.wixproj @@ -0,0 +1,9 @@ + + + + {78FBE6B9-7BA5-444B-A2B8-489820FA2C89} + + + + + \ No newline at end of file -- cgit v1.2.3-55-g6feb