@joebigelow / wix-1 / commits / cb3776e5

Handle downgrade failure detection during Detect.

Fixes https://github.com/wixtoolset/issues/issues/6537.

Bob Arnson committed Aug 21, 2022 at 23:55 UTC cb3776e5e3e075e8e4fe2ae7231ec19f3345c546
2 files changed +43 -16
src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp
+28 -16
@@ -322,6 +322,21 @@ public: // IBootstrapperApplication
322 // Best effort
323 }
324
325 + if (BOOTSTRAPPER_ACTION_INSTALL == m_command.action && BOOTSTRAPPER_RELATION_UPGRADE == relationType)
326 + {
327 + int nResult = 0;
328 + HRESULT hr = VerCompareStringVersions(m_sczBundleVersion, wzVersion, TRUE/*fStrict*/, &nResult);
329 + BalExitOnFailure(hr, "Failed to compare bundle version: %ls to related bundle version: %ls.", m_sczBundleVersion, wzVersion);
330 +
331 + if (0 > nResult)
332 + {
333 + m_fDowngrading = TRUE;
334 +
335 + BalLog(BOOTSTRAPPER_LOG_LEVEL_VERBOSE, "Related bundle version: %ls is a downgrade for bundle version: %ls.", wzVersion, m_sczBundleVersion);
336 + }
337 + }
338 +
339 + LExit:
340 return CBalBaseBootstrapperApplication::OnDetectRelatedBundle(wzBundleId, relationType, wzBundleTag, fPerMachine, wzVersion, fMissingFromCache, pfCancel);
341 }
342
@@ -333,6 +348,15 @@ public: // IBootstrapperApplication
348 {
349 HRESULT hr = S_OK;
350
351 + if (m_fSuppressDowngradeFailure && m_fDowngrading)
352 + {
353 + SetState(WIXSTDBA_STATE_APPLIED, hrStatus);
354 +
355 + BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Bundle downgrade was attempted but downgrade failure has been suppressed.");
356 +
357 + ExitFunction();
358 + }
359 +
360 // If we're not interacting with the user or we're doing a layout or we're resuming just after a force restart
361 // then automatically start planning.
362 BOOL fSkipToPlan = SUCCEEDED(hrStatus) &&
@@ -365,6 +389,7 @@ public: // IBootstrapperApplication
389 }
390 }
391
392 + LExit:
393 return hr;
394 }
395
@@ -1188,21 +1213,6 @@ public: // IBootstrapperApplication
1213 return hr;
1214 }
1215
1191 - virtual STDMETHODIMP OnApplyDowngrade(
1192 - __in HRESULT /*hrRecommendation*/,
1193 - __in HRESULT* phrStatus
1194 - )
1195 - {
1196 - HRESULT hr = S_OK;
1197 -
1198 - if (m_fSuppressDowngradeFailure)
1199 - {
1200 - *phrStatus = S_OK;
1201 - }
1202 -
1203 - return hr;
1204 - }
1205 -
1216 virtual STDMETHODIMP OnApplyComplete(
1217 __in HRESULT hrStatus,
1218 __in BOOTSTRAPPER_APPLY_RESTART restart,
@@ -3888,7 +3898,7 @@ private:
3898 hr = ThemeShowPage(m_pTheme, dwNewPageId, SW_SHOW);
3899 if (FAILED(hr))
3900 {
3891 - BalLogError(hr, "Failed to show page: %u", dwOldPageId);
3901 + BalLogError(hr, "Failed to show page: %u", dwNewPageId);
3902 }
3903
3904 // On the install page set the focus to the install button or the next enabled control if install is disabled.
@@ -4643,6 +4653,7 @@ public:
4653 m_sczLicenseFile = NULL;
4654 m_sczLicenseUrl = NULL;
4655 m_fSuppressDowngradeFailure = FALSE;
4656 + m_fDowngrading = FALSE;
4657 m_fSuppressRepair = FALSE;
4658 m_fSupportCacheOnly = FALSE;
4659 m_fRequestedCacheOnly = FALSE;
@@ -4949,6 +4960,7 @@ private:
4960 LPWSTR m_sczLicenseFile;
4961 LPWSTR m_sczLicenseUrl;
4962 BOOL m_fSuppressDowngradeFailure;
4963 + BOOL m_fDowngrading;
4964 BOOL m_fSuppressRepair;
4965 BOOL m_fSupportCacheOnly;
4966 BOOL m_fRequestedCacheOnly;
src/test/burn/TestData/WixStdBaTests/BundleA/BundleA_v13.wixproj new
+15
@@ -0,0 +1,15 @@
1 +<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->
2 +<Project Sdk="WixToolset.Sdk">
3 + <PropertyGroup>
4 + <OutputType>Bundle</OutputType>
5 + <UpgradeCode>{7D977157-06C9-4176-A931-AC16E18AAB51}</UpgradeCode>
6 + <DefineConstants>$(DefineConstants);Version=1.3</DefineConstants>
7 + <OutputName>WixStdBaTest1_v13</OutputName>
8 + </PropertyGroup>
9 + <ItemGroup>
10 + <ProjectReference Include="..\PackageA\PackageA.wixproj" />
11 + </ItemGroup>
12 + <ItemGroup>
13 + <PackageReference Include="WixToolset.Bal.wixext" />
14 + </ItemGroup>
15 +</Project>
\ No newline at end of file