@joebigelow / wix / commits / a981e29d

Make the estimated size in ARP a little more accurate.

Fixes 4039

Sean Hall committed Apr 22, 2022 at 16:56 UTC a981e29d7a3df566754356c3fe1eb938a5cac4c1
17 files changed +177 -113
src/burn/engine/apply.cpp
+31 -12
@@ -79,7 +79,8 @@ static HRESULT WINAPI AuthenticationRequired(
79 static void CalculateKeepRegistration(
80 __in BURN_ENGINE_STATE* pEngineState,
81 __in BOOL fLog,
82 - __inout BOOTSTRAPPER_REGISTRATION_TYPE* pRegistrationType
82 + __inout BOOTSTRAPPER_REGISTRATION_TYPE* pRegistrationType,
83 + __inout DWORD64* pqwEstimatedSize
84 );
85 static HRESULT ExecuteDependentRegistrationActions(
86 __in HANDLE hPipe,
@@ -422,8 +423,9 @@ extern "C" HRESULT ApplyRegister(
423 HRESULT hr = S_OK;
424 LPWSTR sczEngineWorkingPath = NULL;
425 BOOTSTRAPPER_REGISTRATION_TYPE registrationType = BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS;
426 + DWORD64 qwEstimatedSize = 0;
427
426 - CalculateKeepRegistration(pEngineState, FALSE, &registrationType);
428 + CalculateKeepRegistration(pEngineState, FALSE, &registrationType, &qwEstimatedSize);
429
430 hr = UserExperienceOnRegisterBegin(&pEngineState->userExperience, &registrationType);
431 ExitOnRootFailure(hr, "BA aborted register begin.");
@@ -451,12 +453,12 @@ extern "C" HRESULT ApplyRegister(
453 // begin new session
454 if (pEngineState->registration.fPerMachine)
455 {
454 - hr = ElevationSessionBegin(pEngineState->companionConnection.hPipe, sczEngineWorkingPath, pEngineState->registration.sczResumeCommandLine, pEngineState->registration.fDisableResume, &pEngineState->variables, pEngineState->plan.dwRegistrationOperations, pEngineState->registration.fDetectedForeignProviderKeyBundleId, pEngineState->plan.qwEstimatedSize, registrationType);
456 + hr = ElevationSessionBegin(pEngineState->companionConnection.hPipe, sczEngineWorkingPath, pEngineState->registration.sczResumeCommandLine, pEngineState->registration.fDisableResume, &pEngineState->variables, pEngineState->plan.dwRegistrationOperations, pEngineState->registration.fDetectedForeignProviderKeyBundleId, qwEstimatedSize, registrationType);
457 ExitOnFailure(hr, "Failed to begin registration session in per-machine process.");
458 }
459 else
460 {
459 - hr = RegistrationSessionBegin(sczEngineWorkingPath, &pEngineState->registration, &pEngineState->cache, &pEngineState->variables, pEngineState->plan.dwRegistrationOperations, pEngineState->plan.qwEstimatedSize, registrationType);
461 + hr = RegistrationSessionBegin(sczEngineWorkingPath, &pEngineState->registration, &pEngineState->cache, &pEngineState->variables, pEngineState->plan.dwRegistrationOperations, qwEstimatedSize, registrationType);
462 ExitOnFailure(hr, "Failed to begin registration session.");
463 }
464 }
@@ -491,6 +493,7 @@ extern "C" HRESULT ApplyUnregister(
493 BURN_RESUME_MODE resumeMode = BURN_RESUME_MODE_NONE;
494 BOOTSTRAPPER_REGISTRATION_TYPE defaultRegistrationType = BOOTSTRAPPER_REGISTRATION_TYPE_NONE;
495 BOOTSTRAPPER_REGISTRATION_TYPE registrationType = BOOTSTRAPPER_REGISTRATION_TYPE_NONE;
496 + DWORD64 qwEstimatedSize = 0;
497
498 // Calculate special cases for the resume mode. If a restart has been initiated, that trumps all other
499 // modes. If the user chose to suspend the install then we'll use that as the resume mode.
@@ -513,7 +516,7 @@ extern "C" HRESULT ApplyUnregister(
516 defaultRegistrationType = BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS;
517 }
518
516 - CalculateKeepRegistration(pEngineState, TRUE, &defaultRegistrationType);
519 + CalculateKeepRegistration(pEngineState, TRUE, &defaultRegistrationType, &qwEstimatedSize);
520
521 registrationType = defaultRegistrationType;
522
@@ -547,12 +550,12 @@ extern "C" HRESULT ApplyUnregister(
550
551 if (pEngineState->registration.fPerMachine)
552 {
550 - hr = ElevationSessionEnd(pEngineState->companionConnection.hPipe, resumeMode, restart, pEngineState->registration.fDetectedForeignProviderKeyBundleId, registrationType);
553 + hr = ElevationSessionEnd(pEngineState->companionConnection.hPipe, resumeMode, restart, pEngineState->registration.fDetectedForeignProviderKeyBundleId, qwEstimatedSize, registrationType);
554 ExitOnFailure(hr, "Failed to end session in per-machine process.");
555 }
556 else
557 {
555 - hr = RegistrationSessionEnd(&pEngineState->registration, &pEngineState->cache, &pEngineState->variables, &pEngineState->packages, resumeMode, restart, registrationType);
558 + hr = RegistrationSessionEnd(&pEngineState->registration, &pEngineState->cache, &pEngineState->variables, &pEngineState->packages, resumeMode, restart, qwEstimatedSize, registrationType);
559 ExitOnFailure(hr, "Failed to end session in per-user process.");
560 }
561
@@ -880,9 +883,12 @@ extern "C" void ApplyClean(
883 static void CalculateKeepRegistration(
884 __in BURN_ENGINE_STATE* pEngineState,
885 __in BOOL fLog,
883 - __inout BOOTSTRAPPER_REGISTRATION_TYPE* pRegistrationType
886 + __inout BOOTSTRAPPER_REGISTRATION_TYPE* pRegistrationType,
887 + __inout DWORD64* pqwEstimatedSize
888 )
889 {
890 + DWORD64 qwEstimatedSize = pEngineState->section.qwBundleSize;
891 +
892 if (fLog)
893 {
894 LogId(REPORT_STANDARD, MSG_POST_APPLY_CALCULATE_REGISTRATION);
@@ -911,16 +917,29 @@ static void CalculateKeepRegistration(
917 {
918 *pRegistrationType = BOOTSTRAPPER_REGISTRATION_TYPE_FULL;
919
914 - if (!fLog)
920 + if (BURN_PACKAGE_TYPE_MSP == pPackage->type)
921 {
916 - break;
922 + qwEstimatedSize += pPackage->qwSize;
923 }
924 +
925 + qwEstimatedSize += pPackage->qwInstallSize;
926 }
919 - else if (BURN_PACKAGE_REGISTRATION_STATE_PRESENT == pPackage->cacheRegistrationState && BOOTSTRAPPER_REGISTRATION_TYPE_NONE == *pRegistrationType)
927 +
928 + if (BURN_PACKAGE_REGISTRATION_STATE_PRESENT == pPackage->cacheRegistrationState)
929 {
921 - *pRegistrationType = BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS;
930 + if (BOOTSTRAPPER_REGISTRATION_TYPE_NONE == *pRegistrationType)
931 + {
932 + *pRegistrationType = BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS;
933 + }
934 +
935 + qwEstimatedSize += pPackage->qwSize;
936 }
937 }
938 +
939 + if (pqwEstimatedSize)
940 + {
941 + *pqwEstimatedSize = qwEstimatedSize;
942 + }
943 }
944
945 static HRESULT ExecuteDependentRegistrationActions(
src/burn/engine/elevation.cpp
+9 -1
@@ -636,6 +636,7 @@ extern "C" HRESULT ElevationSessionEnd(
636 __in BURN_RESUME_MODE resumeMode,
637 __in BOOTSTRAPPER_APPLY_RESTART restart,
638 __in BOOL fDetectedForeignProviderKeyBundleId,
639 + __in DWORD64 qwEstimatedSize,
640 __in BOOTSTRAPPER_REGISTRATION_TYPE registrationType
641 )
642 {
@@ -654,6 +655,9 @@ extern "C" HRESULT ElevationSessionEnd(
655 hr = BuffWriteNumber(&pbData, &cbData, (DWORD)fDetectedForeignProviderKeyBundleId);
656 ExitOnFailure(hr, "Failed to write dependency registration action to message buffer.");
657
658 + hr = BuffWriteNumber64(&pbData, &cbData, qwEstimatedSize);
659 + ExitOnFailure(hr, "Failed to write estimated size to message buffer.");
660 +
661 hr = BuffWriteNumber(&pbData, &cbData, (DWORD)registrationType);
662 ExitOnFailure(hr, "Failed to write registration type to message buffer.");
663
@@ -2580,6 +2584,7 @@ static HRESULT OnSessionEnd(
2584 SIZE_T iData = 0;
2585 DWORD dwResumeMode = 0;
2586 DWORD dwRestart = 0;
2587 + DWORD64 qwEstimatedSize = 0;
2588 DWORD dwRegistrationType = 0;
2589
2590 // Deserialize message data.
@@ -2592,11 +2597,14 @@ static HRESULT OnSessionEnd(
2597 hr = BuffReadNumber(pbData, cbData, &iData, (DWORD*)&pRegistration->fDetectedForeignProviderKeyBundleId);
2598 ExitOnFailure(hr, "Failed to read dependency registration action.");
2599
2600 + hr = BuffReadNumber64(pbData, cbData, &iData, &qwEstimatedSize);
2601 + ExitOnFailure(hr, "Failed to read estimated size.");
2602 +
2603 hr = BuffReadNumber(pbData, cbData, &iData, &dwRegistrationType);
2604 ExitOnFailure(hr, "Failed to read dependency registration action.");
2605
2606 // suspend session in per-machine process
2599 - hr = RegistrationSessionEnd(pRegistration, pCache, pVariables, pPackages, (BURN_RESUME_MODE)dwResumeMode, (BOOTSTRAPPER_APPLY_RESTART)dwRestart, (BOOTSTRAPPER_REGISTRATION_TYPE)dwRegistrationType);
2607 + hr = RegistrationSessionEnd(pRegistration, pCache, pVariables, pPackages, (BURN_RESUME_MODE)dwResumeMode, (BOOTSTRAPPER_APPLY_RESTART)dwRestart, qwEstimatedSize, (BOOTSTRAPPER_REGISTRATION_TYPE)dwRegistrationType);
2608 ExitOnFailure(hr, "Failed to suspend registration session.");
2609
2610 LExit:
src/burn/engine/elevation.h
+1
@@ -44,6 +44,7 @@ HRESULT ElevationSessionEnd(
44 __in BURN_RESUME_MODE resumeMode,
45 __in BOOTSTRAPPER_APPLY_RESTART restart,
46 __in BOOL fDetectedForeignProviderKeyBundleId,
47 + __in DWORD64 qwEstimatedSize,
48 __in BOOTSTRAPPER_REGISTRATION_TYPE registrationType
49 );
50 HRESULT ElevationSaveState(
src/burn/engine/plan.cpp
-26
@@ -1178,31 +1178,6 @@ extern "C" HRESULT PlanExecutePackage(
1178 pPackage->rollback = BOOTSTRAPPER_ACTION_STATE_NONE;
1179 }
1180
1181 - // Add the cache and install size to estimated size if it will be on the machine at the end of the install
1182 - if (BOOTSTRAPPER_REQUEST_STATE_PRESENT == pPackage->requested ||
1183 - fRequestedCache ||
1184 - (BOOTSTRAPPER_PACKAGE_STATE_PRESENT == pPackage->currentState && BOOTSTRAPPER_REQUEST_STATE_ABSENT < pPackage->requested)
1185 - )
1186 - {
1187 - // If the package will remain in the cache, add the package size to the estimated size
1188 - if (BOOTSTRAPPER_CACHE_TYPE_REMOVE < pPackage->cacheType)
1189 - {
1190 - pPlan->qwEstimatedSize += pPackage->qwSize;
1191 - }
1192 -
1193 - // If the package will end up installed on the machine, add the install size to the estimated size.
1194 - if (BOOTSTRAPPER_REQUEST_STATE_CACHE < pPackage->requested)
1195 - {
1196 - // MSP packages get cached automatically by windows installer with any embedded cabs, so include that in the size as well
1197 - if (BURN_PACKAGE_TYPE_MSP == pPackage->type)
1198 - {
1199 - pPlan->qwEstimatedSize += pPackage->qwSize;
1200 - }
1201 -
1202 - pPlan->qwEstimatedSize += pPackage->qwInstallSize;
1203 - }
1204 - }
1205 -
1181 // Add execute actions.
1182 switch (pPackage->type)
1183 {
@@ -3079,7 +3054,6 @@ extern "C" void PlanDump(
3054 LogStringLine(PlanDumpLevel, " disallow-removal: %hs", LoggingTrueFalseToString(pPlan->fDisallowRemoval));
3055 LogStringLine(PlanDumpLevel, " downgrade: %hs", LoggingTrueFalseToString(pPlan->fDowngrade));
3056 LogStringLine(PlanDumpLevel, " registration options: %hs", LoggingRegistrationOptionsToString(pPlan->dwRegistrationOperations));
3082 - LogStringLine(PlanDumpLevel, " estimated size: %llu", pPlan->qwEstimatedSize);
3057 if (pPlan->sczLayoutDirectory)
3058 {
3059 LogStringLine(PlanDumpLevel, " layout directory: %ls", pPlan->sczLayoutDirectory);
src/burn/engine/plan.h
-2
@@ -267,8 +267,6 @@ typedef struct _BURN_PLAN
267
268 DWORD64 qwCacheSizeTotal;
269
270 - DWORD64 qwEstimatedSize;
271 -
270 DWORD cExecutePackagesTotal;
271 DWORD cOverallProgressTicksTotal;
272
src/burn/engine/registration.cpp
+44 -17
@@ -102,6 +102,10 @@ static HRESULT UpdateBundleNameRegistration(
102 __in HKEY hkRegistration,
103 __in BOOL fInProgressRegistration
104 );
105 +static HRESULT UpdateEstimatedSize(
106 + __in HKEY hkRegistration,
107 + __in DWORD64 qwEstimatedSize
108 + );
109 static BOOL IsWuRebootPending();
110 static BOOL IsRegistryRebootPending();
111
@@ -600,8 +604,8 @@ extern "C" HRESULT RegistrationSessionBegin(
604 )
605 {
606 HRESULT hr = S_OK;
603 - DWORD dwSize = 0;
607 HKEY hkRegistration = NULL;
608 + BOOL fCreated = FALSE;
609 LPWSTR sczPublisher = NULL;
610
611 AssertSz(BOOTSTRAPPER_REGISTRATION_TYPE_NONE != registrationType, "Registration type can't be NONE");
@@ -620,7 +624,7 @@ extern "C" HRESULT RegistrationSessionBegin(
624 }
625
626 // create registration key
623 - hr = RegCreate(pRegistration->hkRoot, pRegistration->sczRegistrationKey, KEY_WRITE, &hkRegistration);
627 + hr = RegCreateEx(pRegistration->hkRoot, pRegistration->sczRegistrationKey, KEY_WRITE, REG_KEY_DEFAULT, FALSE, NULL, &hkRegistration, &fCreated);
628 ExitOnFailure(hr, "Failed to create registration key.");
629
630 // Write any ARP values and software tags.
@@ -797,22 +801,12 @@ extern "C" HRESULT RegistrationSessionBegin(
801 ExitOnFailure(hr, "Failed to write update registration.");
802 }
803
800 - // Update estimated size.
801 - qwEstimatedSize /= 1024; // Convert bytes to KB
802 - if (0 < qwEstimatedSize)
804 + // Only set estimated size here for the first time.
805 + // It will always get updated at the end of the session.
806 + if (fCreated)
807 {
804 - if (DWORD_MAX < qwEstimatedSize)
805 - {
806 - // ARP doesn't support QWORDs here
807 - dwSize = DWORD_MAX;
808 - }
809 - else
810 - {
811 - dwSize = static_cast<DWORD>(qwEstimatedSize);
812 - }
813 -
814 - hr = RegWriteNumber(hkRegistration, REGISTRY_BUNDLE_ESTIMATED_SIZE, dwSize);
815 - ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_ESTIMATED_SIZE);
808 + hr = UpdateEstimatedSize(hkRegistration, qwEstimatedSize);
809 + ExitOnFailure(hr, "Failed to update estimated size.");
810 }
811
812 // Register the bundle dependency key.
@@ -879,6 +873,7 @@ extern "C" HRESULT RegistrationSessionEnd(
873 __in BURN_PACKAGES* pPackages,
874 __in BURN_RESUME_MODE resumeMode,
875 __in BOOTSTRAPPER_APPLY_RESTART restart,
876 + __in DWORD64 qwEstimatedSize,
877 __in BOOTSTRAPPER_REGISTRATION_TYPE registrationType
878 )
879 {
@@ -921,6 +916,9 @@ extern "C" HRESULT RegistrationSessionEnd(
916 // update display name
917 hr = UpdateBundleNameRegistration(pRegistration, pVariables, hkRegistration, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS == registrationType);
918 ExitOnFailure(hr, "Failed to update name and publisher.");
919 +
920 + hr = UpdateEstimatedSize(hkRegistration, qwEstimatedSize);
921 + ExitOnFailure(hr, "Failed to update estimated size.");
922 }
923
924 // Update resume mode.
@@ -1604,6 +1602,35 @@ LExit:
1602 return hr;
1603 }
1604
1605 +static HRESULT UpdateEstimatedSize(
1606 + __in HKEY hkRegistration,
1607 + __in DWORD64 qwEstimatedSize
1608 + )
1609 +{
1610 + HRESULT hr = S_OK;
1611 + DWORD dwSize = 0;
1612 +
1613 + qwEstimatedSize /= 1024; // Convert bytes to KB
1614 + if (0 < qwEstimatedSize)
1615 + {
1616 + if (DWORD_MAX < qwEstimatedSize)
1617 + {
1618 + // ARP doesn't support QWORDs here
1619 + dwSize = DWORD_MAX;
1620 + }
1621 + else
1622 + {
1623 + dwSize = static_cast<DWORD>(qwEstimatedSize);
1624 + }
1625 +
1626 + hr = RegWriteNumber(hkRegistration, REGISTRY_BUNDLE_ESTIMATED_SIZE, dwSize);
1627 + ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_ESTIMATED_SIZE);
1628 + }
1629 +
1630 +LExit:
1631 + return hr;
1632 +}
1633 +
1634 static BOOL IsWuRebootPending()
1635 {
1636 HRESULT hr = S_OK;
src/burn/engine/registration.h
+1
@@ -213,6 +213,7 @@ HRESULT RegistrationSessionEnd(
213 __in BURN_PACKAGES* pPackages,
214 __in BURN_RESUME_MODE resumeMode,
215 __in BOOTSTRAPPER_APPLY_RESTART restart,
216 + __in DWORD64 qwEstimatedSize,
217 __in BOOTSTRAPPER_REGISTRATION_TYPE registrationType
218 );
219 HRESULT RegistrationSaveState(
src/burn/test/BurnUnitTest/PlanTest.cpp
+2 -23
@@ -106,7 +106,6 @@ namespace Bootstrapper
106 ValidateCacheCheckpoint(pPlan, fRollback, dwIndex++, 14);
107 Assert::Equal(dwIndex, pPlan->cRollbackCacheActions);
108
109 - Assert::Equal(107082ull, pPlan->qwEstimatedSize);
109 Assert::Equal(522548ull, pPlan->qwCacheSizeTotal);
110
111 fRollback = FALSE;
@@ -252,7 +251,6 @@ namespace Bootstrapper
251 dwIndex = 0;
252 Assert::Equal(dwIndex, pPlan->cRollbackCacheActions);
253
255 - Assert::Equal(0ull, pPlan->qwEstimatedSize);
254 Assert::Equal(0ull, pPlan->qwCacheSizeTotal);
255
256 fRollback = FALSE;
@@ -392,7 +390,6 @@ namespace Bootstrapper
390 dwIndex = 0;
391 Assert::Equal(dwIndex, pPlan->cRollbackCacheActions);
392
395 - Assert::Equal(18575450ull, pPlan->qwEstimatedSize);
393 Assert::Equal(78462280ull, pPlan->qwCacheSizeTotal);
394
395 fRollback = FALSE;
@@ -503,7 +500,6 @@ namespace Bootstrapper
500 dwIndex = 0;
501 Assert::Equal(dwIndex, pPlan->cRollbackCacheActions);
502
506 - Assert::Equal(18575450ull, pPlan->qwEstimatedSize);
503 Assert::Equal(52254105ull, pPlan->qwCacheSizeTotal);
504
505 fRollback = FALSE;
@@ -595,7 +591,6 @@ namespace Bootstrapper
591 dwIndex = 0;
592 Assert::Equal(dwIndex, pPlan->cRollbackCacheActions);
593
598 - Assert::Equal(0ull, pPlan->qwEstimatedSize);
594 Assert::Equal(0ull, pPlan->qwCacheSizeTotal);
595
596 fRollback = FALSE;
@@ -703,7 +698,6 @@ namespace Bootstrapper
698 ValidateCacheCheckpoint(pPlan, fRollback, dwIndex++, 1);
699 Assert::Equal(dwIndex, pPlan->cRollbackCacheActions);
700
706 - Assert::Equal(35694ull, pPlan->qwEstimatedSize);
701 Assert::Equal(168715ull, pPlan->qwCacheSizeTotal);
702
703 fRollback = FALSE;
@@ -823,7 +817,6 @@ namespace Bootstrapper
817 ValidateCacheCheckpoint(pPlan, fRollback, dwIndex++, 1);
818 Assert::Equal(dwIndex, pPlan->cRollbackCacheActions);
819
826 - Assert::Equal(35694ull, pPlan->qwEstimatedSize);
820 Assert::Equal(168715ull, pPlan->qwCacheSizeTotal);
821
822 fRollback = FALSE;
@@ -924,7 +917,6 @@ namespace Bootstrapper
917 dwIndex = 0;
918 Assert::Equal(dwIndex, pPlan->cRollbackCacheActions);
919
927 - Assert::Equal(1463267ull, pPlan->qwEstimatedSize);
920 Assert::Equal(119695ull, pPlan->qwCacheSizeTotal);
921
922 fRollback = FALSE;
@@ -1021,7 +1013,6 @@ namespace Bootstrapper
1013 ValidateCacheCheckpoint(pPlan, fRollback, dwIndex++, 1);
1014 Assert::Equal(dwIndex, pPlan->cRollbackCacheActions);
1015
1024 - Assert::Equal(33743ull, pPlan->qwEstimatedSize);
1016 Assert::Equal(168715ull, pPlan->qwCacheSizeTotal);
1017
1018 fRollback = FALSE;
@@ -1104,7 +1095,6 @@ namespace Bootstrapper
1095 dwIndex = 0;
1096 Assert::Equal(dwIndex, pPlan->cRollbackCacheActions);
1097
1107 - Assert::Equal(0ull, pPlan->qwEstimatedSize);
1098 Assert::Equal(0ull, pPlan->qwCacheSizeTotal);
1099
1100 fRollback = FALSE;
@@ -1180,7 +1170,6 @@ namespace Bootstrapper
1170 dwIndex = 0;
1171 Assert::Equal(dwIndex, pPlan->cRollbackCacheActions);
1172
1183 - Assert::Equal(0ull, pPlan->qwEstimatedSize);
1173 Assert::Equal(0ull, pPlan->qwCacheSizeTotal);
1174
1175 fRollback = FALSE;
@@ -1273,7 +1262,6 @@ namespace Bootstrapper
1262 dwIndex = 0;
1263 Assert::Equal(dwIndex, pPlan->cRollbackCacheActions);
1264
1276 - Assert::Equal(35694ull, pPlan->qwEstimatedSize);
1265 Assert::Equal(175674ull, pPlan->qwCacheSizeTotal);
1266
1267 fRollback = FALSE;
@@ -1371,7 +1359,6 @@ namespace Bootstrapper
1359 ValidateCacheCheckpoint(pPlan, fRollback, dwIndex++, 1);
1360 Assert::Equal(dwIndex, pPlan->cRollbackCacheActions);
1361
1374 - Assert::Equal(35694ull, pPlan->qwEstimatedSize);
1362 Assert::Equal(168715ull, pPlan->qwCacheSizeTotal);
1363
1364 fRollback = FALSE;
@@ -1473,7 +1460,6 @@ namespace Bootstrapper
1460 dwIndex = 0;
1461 Assert::Equal(dwIndex, pPlan->cRollbackCacheActions);
1462
1476 - Assert::Equal(0ull, pPlan->qwEstimatedSize);
1463 Assert::Equal(0ull, pPlan->qwCacheSizeTotal);
1464
1465 fRollback = FALSE;
@@ -1553,7 +1539,6 @@ namespace Bootstrapper
1539 dwIndex = 0;
1540 Assert::Equal(dwIndex, pPlan->cRollbackCacheActions);
1541
1556 - Assert::Equal(0ull, pPlan->qwEstimatedSize);
1542 Assert::Equal(0ull, pPlan->qwCacheSizeTotal);
1543
1544 fRollback = FALSE;
@@ -1649,7 +1634,6 @@ namespace Bootstrapper
1634 dwIndex = 0;
1635 Assert::Equal(dwIndex, pPlan->cRollbackCacheActions);
1636
1652 - Assert::Equal(0ull, pPlan->qwEstimatedSize);
1637 Assert::Equal(0ull, pPlan->qwCacheSizeTotal);
1638
1639 fRollback = FALSE;
@@ -1720,7 +1704,6 @@ namespace Bootstrapper
1704 dwIndex = 0;
1705 Assert::Equal(dwIndex, pPlan->cRollbackCacheActions);
1706
1723 - Assert::Equal(0ull, pPlan->qwEstimatedSize);
1707 Assert::Equal(0ull, pPlan->qwCacheSizeTotal);
1708
1709 fRollback = FALSE;
@@ -1805,7 +1788,6 @@ namespace Bootstrapper
1788 dwIndex = 0;
1789 Assert::Equal(dwIndex, pPlan->cRollbackCacheActions);
1790
1808 - Assert::Equal(0ull, pPlan->qwEstimatedSize);
1791 Assert::Equal(0ull, pPlan->qwCacheSizeTotal);
1792
1793 fRollback = FALSE;
@@ -1906,7 +1888,6 @@ namespace Bootstrapper
1888 ValidateCacheCheckpoint(pPlan, fRollback, dwIndex++, 1);
1889 Assert::Equal(dwIndex, pPlan->cRollbackCacheActions);
1890
1909 - Assert::Equal(56ull, pPlan->qwEstimatedSize);
1891 Assert::Equal(140ull, pPlan->qwCacheSizeTotal);
1892
1893 fRollback = FALSE;
@@ -2005,7 +1986,6 @@ namespace Bootstrapper
1986 dwIndex = 0;
1987 Assert::Equal(dwIndex, pPlan->cRollbackCacheActions);
1988
2008 - Assert::Equal(3055111ull, pPlan->qwEstimatedSize);
1989 Assert::Equal(6130592ull, pPlan->qwCacheSizeTotal);
1990
1991 fRollback = FALSE;
@@ -2128,7 +2108,6 @@ namespace Bootstrapper
2108 dwIndex = 0;
2109 Assert::Equal(dwIndex, pPlan->cRollbackCacheActions);
2110
2131 - Assert::Equal(0ull, pPlan->qwEstimatedSize);
2111 Assert::Equal(0ull, pPlan->qwCacheSizeTotal);
2112
2113 fRollback = FALSE;
@@ -2245,7 +2224,6 @@ namespace Bootstrapper
2224 dwIndex = 0;
2225 Assert::Equal(dwIndex, pPlan->cRollbackCacheActions);
2226
2248 - Assert::Equal(0ull, pPlan->qwEstimatedSize);
2227 Assert::Equal(0ull, pPlan->qwCacheSizeTotal);
2228
2229 fRollback = FALSE;
@@ -2351,7 +2329,6 @@ namespace Bootstrapper
2329 ValidateCacheCheckpoint(pPlan, fRollback, dwIndex++, 4);
2330 Assert::Equal(dwIndex, pPlan->cRollbackCacheActions);
2331
2354 - Assert::Equal(2993671ull, pPlan->qwEstimatedSize);
2332 Assert::Equal(6048672ull, pPlan->qwCacheSizeTotal);
2333
2334 fRollback = FALSE;
@@ -2451,6 +2428,8 @@ namespace Bootstrapper
2428 ReleaseStr(sczFilePath);
2429 }
2430
2431 + pEngineState->section.qwBundleSize = 1234;
2432 +
2433 hr = CoreInitializeConstants(pEngineState);
2434 NativeAssert::Succeeded(hr, "Failed to initialize core constants");
2435
src/burn/test/BurnUnitTest/RegistrationTest.cpp
+24 -18
@@ -60,6 +60,7 @@ namespace Bootstrapper
60 String^ cacheDirectory = Path::Combine(Path::Combine(Environment::GetFolderPath(Environment::SpecialFolder::LocalApplicationData), gcnew String(L"Package Cache")), gcnew String(TEST_BUNDLE_ID));
61 String^ cacheExePath = Path::Combine(cacheDirectory, gcnew String(L"setup.exe"));
62 DWORD dwRegistrationOptions = BURN_REGISTRATION_ACTION_OPERATIONS_CACHE_BUNDLE;
63 + DWORD64 qwEstimatedSize = 1024;
64
65 try
66 {
@@ -103,7 +104,7 @@ namespace Bootstrapper
104 TestThrowOnFailure(hr, L"Failed to get current process path.");
105
106 // write registration
106 - hr = RegistrationSessionBegin(sczCurrentProcess, &registration, &cache, &variables, dwRegistrationOptions, 0, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS);
107 + hr = RegistrationSessionBegin(sczCurrentProcess, &registration, &cache, &variables, dwRegistrationOptions, qwEstimatedSize, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS);
108 TestThrowOnFailure(hr, L"Failed to register bundle.");
109
110 // verify that registration was created
@@ -114,7 +115,7 @@ namespace Bootstrapper
115 this->ValidateRunOnceKeyEntry(cacheExePath);
116
117 // end session
117 - hr = RegistrationSessionEnd(&registration, &cache, &variables, &packages, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, BOOTSTRAPPER_REGISTRATION_TYPE_NONE);
118 + hr = RegistrationSessionEnd(&registration, &cache, &variables, &packages, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, qwEstimatedSize, BOOTSTRAPPER_REGISTRATION_TYPE_NONE);
119 TestThrowOnFailure(hr, L"Failed to unregister bundle.");
120
121 // verify that registration was removed
@@ -158,6 +159,7 @@ namespace Bootstrapper
159 String^ cacheDirectory = Path::Combine(Path::Combine(Environment::GetFolderPath(Environment::SpecialFolder::LocalApplicationData), gcnew String(L"Package Cache")), gcnew String(TEST_BUNDLE_ID));
160 String^ cacheExePath = Path::Combine(cacheDirectory, gcnew String(L"setup.exe"));
161 DWORD dwRegistrationOptions = 0;
162 + DWORD64 qwEstimatedSize = 1024;
163 try
164 {
165 this->testRegistry->SetUp();
@@ -204,7 +206,7 @@ namespace Bootstrapper
206 //
207
208 // write registration
207 - hr = RegistrationSessionBegin(sczCurrentProcess, &registration, &cache, &variables, dwRegistrationOptions, 0, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS);
209 + hr = RegistrationSessionBegin(sczCurrentProcess, &registration, &cache, &variables, dwRegistrationOptions, qwEstimatedSize, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS);
210 TestThrowOnFailure(hr, L"Failed to register bundle.");
211
212 // verify that registration was created
@@ -213,7 +215,7 @@ namespace Bootstrapper
215 this->ValidateRunOnceKeyEntry(cacheExePath);
216
217 // complete registration
216 - hr = RegistrationSessionEnd(&registration, &cache, &variables, &packages, BURN_RESUME_MODE_ARP, BOOTSTRAPPER_APPLY_RESTART_NONE, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS);
218 + hr = RegistrationSessionEnd(&registration, &cache, &variables, &packages, BURN_RESUME_MODE_ARP, BOOTSTRAPPER_APPLY_RESTART_NONE, qwEstimatedSize, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS);
219 TestThrowOnFailure(hr, L"Failed to unregister bundle.");
220
221 // verify that registration was updated
@@ -226,7 +228,7 @@ namespace Bootstrapper
228 //
229
230 // write registration
229 - hr = RegistrationSessionBegin(sczCurrentProcess, &registration, &cache, &variables, dwRegistrationOptions, 0, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS);
231 + hr = RegistrationSessionBegin(sczCurrentProcess, &registration, &cache, &variables, dwRegistrationOptions, qwEstimatedSize, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS);
232 TestThrowOnFailure(hr, L"Failed to register bundle.");
233
234 // verify that registration was updated
@@ -235,7 +237,7 @@ namespace Bootstrapper
237 this->ValidateRunOnceKeyEntry(cacheExePath);
238
239 // delete registration
238 - hr = RegistrationSessionEnd(&registration, &cache, &variables, &packages, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, BOOTSTRAPPER_REGISTRATION_TYPE_NONE);
240 + hr = RegistrationSessionEnd(&registration, &cache, &variables, &packages, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, qwEstimatedSize, BOOTSTRAPPER_REGISTRATION_TYPE_NONE);
241 TestThrowOnFailure(hr, L"Failed to unregister bundle.");
242
243 // verify that registration was removed
@@ -278,6 +280,7 @@ namespace Bootstrapper
280 String^ cacheDirectory = Path::Combine(Path::Combine(Environment::GetFolderPath(Environment::SpecialFolder::LocalApplicationData), gcnew String(L"Package Cache")), gcnew String(TEST_BUNDLE_ID));
281 String^ cacheExePath = Path::Combine(cacheDirectory, gcnew String(L"setup.exe"));
282 DWORD dwRegistrationOptions = 0;
283 + DWORD64 qwEstimatedSize = 1024;
284 try
285 {
286 this->testRegistry->SetUp();
@@ -327,7 +330,7 @@ namespace Bootstrapper
330 //
331
332 // write registration
330 - hr = RegistrationSessionBegin(sczCurrentProcess, &registration, &cache, &variables, dwRegistrationOptions, 0, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS);
333 + hr = RegistrationSessionBegin(sczCurrentProcess, &registration, &cache, &variables, dwRegistrationOptions, qwEstimatedSize, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS);
334 TestThrowOnFailure(hr, L"Failed to register bundle.");
335
336 // verify that registration was created
@@ -335,7 +338,7 @@ namespace Bootstrapper
338 this->ValidateRunOnceKeyEntry(cacheExePath);
339
340 // complete registration
338 - hr = RegistrationSessionEnd(&registration, &cache, &variables, &packages, BURN_RESUME_MODE_ARP, BOOTSTRAPPER_APPLY_RESTART_REQUIRED, BOOTSTRAPPER_REGISTRATION_TYPE_FULL);
341 + hr = RegistrationSessionEnd(&registration, &cache, &variables, &packages, BURN_RESUME_MODE_ARP, BOOTSTRAPPER_APPLY_RESTART_REQUIRED, qwEstimatedSize, BOOTSTRAPPER_REGISTRATION_TYPE_FULL);
342 TestThrowOnFailure(hr, L"Failed to unregister bundle.");
343
344 // verify that registration variables were updated
@@ -355,7 +358,7 @@ namespace Bootstrapper
358 //
359
360 // delete registration
358 - hr = RegistrationSessionEnd(&registration, &cache, &variables, &packages, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, BOOTSTRAPPER_REGISTRATION_TYPE_NONE);
361 + hr = RegistrationSessionEnd(&registration, &cache, &variables, &packages, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, qwEstimatedSize, BOOTSTRAPPER_REGISTRATION_TYPE_NONE);
362 TestThrowOnFailure(hr, L"Failed to unregister bundle.");
363
364 // verify that registration was removed
@@ -398,6 +401,7 @@ namespace Bootstrapper
401 String^ cacheDirectory = Path::Combine(Path::Combine(Environment::GetFolderPath(Environment::SpecialFolder::LocalApplicationData), gcnew String(L"Package Cache")), gcnew String(TEST_BUNDLE_ID));
402 String^ cacheExePath = Path::Combine(cacheDirectory, gcnew String(L"setup.exe"));
403 DWORD dwRegistrationOptions = 0;
404 + DWORD64 qwEstimatedSize = 1024;
405 try
406 {
407 this->testRegistry->SetUp();
@@ -446,7 +450,7 @@ namespace Bootstrapper
450 //
451
452 // write registration
449 - hr = RegistrationSessionBegin(sczCurrentProcess, &registration, &cache, &variables, dwRegistrationOptions, 0, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS);
453 + hr = RegistrationSessionBegin(sczCurrentProcess, &registration, &cache, &variables, dwRegistrationOptions, qwEstimatedSize, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS);
454 TestThrowOnFailure(hr, L"Failed to register bundle.");
455
456 // verify that registration was created
@@ -454,7 +458,7 @@ namespace Bootstrapper
458 this->ValidateRunOnceKeyEntry(cacheExePath);
459
460 // finish registration
457 - hr = RegistrationSessionEnd(&registration, &cache, &variables, &packages, BURN_RESUME_MODE_ARP, BOOTSTRAPPER_APPLY_RESTART_NONE, BOOTSTRAPPER_REGISTRATION_TYPE_FULL);
461 + hr = RegistrationSessionEnd(&registration, &cache, &variables, &packages, BURN_RESUME_MODE_ARP, BOOTSTRAPPER_APPLY_RESTART_NONE, qwEstimatedSize, BOOTSTRAPPER_REGISTRATION_TYPE_FULL);
462 TestThrowOnFailure(hr, L"Failed to register bundle.");
463
464 // verify that registration was updated
@@ -479,7 +483,7 @@ namespace Bootstrapper
483 //
484
485 // write registration
482 - hr = RegistrationSessionBegin(sczCurrentProcess, &registration, &cache, &variables, dwRegistrationOptions, 0, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS);
486 + hr = RegistrationSessionBegin(sczCurrentProcess, &registration, &cache, &variables, dwRegistrationOptions, qwEstimatedSize, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS);
487 TestThrowOnFailure(hr, L"Failed to register bundle.");
488
489 // verify that registration was updated
@@ -487,7 +491,7 @@ namespace Bootstrapper
491 this->ValidateRunOnceKeyEntry(cacheExePath);
492
493 // delete registration
490 - hr = RegistrationSessionEnd(&registration, &cache, &variables, &packages, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, BOOTSTRAPPER_REGISTRATION_TYPE_NONE);
494 + hr = RegistrationSessionEnd(&registration, &cache, &variables, &packages, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, qwEstimatedSize, BOOTSTRAPPER_REGISTRATION_TYPE_NONE);
495 TestThrowOnFailure(hr, L"Failed to unregister bundle.");
496
497 // verify that registration was removed
@@ -533,6 +537,7 @@ namespace Bootstrapper
537 BYTE* pbBuffer = NULL;
538 SIZE_T cbBuffer = 0;
539 DWORD dwRegistrationOptions = 0;
540 + DWORD64 qwEstimatedSize = 1024;
541
542 String^ cacheDirectory = Path::Combine(Path::Combine(Environment::GetFolderPath(Environment::SpecialFolder::LocalApplicationData), gcnew String(L"Package Cache")), gcnew String(TEST_BUNDLE_ID));
543 try
@@ -586,7 +591,7 @@ namespace Bootstrapper
591 TestThrowOnFailure(hr, L"Failed to get current process path.");
592
593 // begin session
589 - hr = RegistrationSessionBegin(sczCurrentProcess, &registration, &cache, &variables, dwRegistrationOptions, 0, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS);
594 + hr = RegistrationSessionBegin(sczCurrentProcess, &registration, &cache, &variables, dwRegistrationOptions, qwEstimatedSize, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS);
595 TestThrowOnFailure(hr, L"Failed to register bundle.");
596
597 VariableSetNumericHelper(&variables, L"MyBurnVariable1", 42);
@@ -629,7 +634,7 @@ namespace Bootstrapper
634 NativeAssert::StringEqual(L"42", sczValue);
635
636 // end session
632 - hr = RegistrationSessionEnd(&registration, &cache, &variables, &packages, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, BOOTSTRAPPER_REGISTRATION_TYPE_NONE);
637 + hr = RegistrationSessionEnd(&registration, &cache, &variables, &packages, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, qwEstimatedSize, BOOTSTRAPPER_REGISTRATION_TYPE_NONE);
638 TestThrowOnFailure(hr, L"Failed to unregister bundle.");
639 }
640 finally
@@ -673,6 +678,7 @@ namespace Bootstrapper
678 String^ cacheDirectory = Path::Combine(Path::Combine(Environment::GetFolderPath(Environment::SpecialFolder::LocalApplicationData), gcnew String(L"Package Cache")), gcnew String(TEST_BUNDLE_ID));
679 String^ cacheExePath = Path::Combine(cacheDirectory, gcnew String(L"setup.exe"));
680 DWORD dwRegistrationOptions = 0;
681 + DWORD64 qwEstimatedSize = 1024;
682 try
683 {
684 this->testRegistry->SetUp();
@@ -728,7 +734,7 @@ namespace Bootstrapper
734 Assert::Equal((int)BOOTSTRAPPER_RESUME_TYPE_NONE, (int)resumeType);
735
736 // begin session
731 - hr = RegistrationSessionBegin(sczCurrentProcess, &registration, &cache, &variables, dwRegistrationOptions, 0, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS);
737 + hr = RegistrationSessionBegin(sczCurrentProcess, &registration, &cache, &variables, dwRegistrationOptions, qwEstimatedSize, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS);
738 TestThrowOnFailure(hr, L"Failed to register bundle.");
739
740 VariableSetNumericHelper(&variables, L"MyBurnVariable1", 42);
@@ -767,7 +773,7 @@ namespace Bootstrapper
773 Assert::Equal((int)BOOTSTRAPPER_RESUME_TYPE_INTERRUPTED, (int)resumeType);
774
775 // suspend session
770 - hr = RegistrationSessionEnd(&registration, &cache, &variables, &packages, BURN_RESUME_MODE_SUSPEND, BOOTSTRAPPER_APPLY_RESTART_NONE, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS);
776 + hr = RegistrationSessionEnd(&registration, &cache, &variables, &packages, BURN_RESUME_MODE_SUSPEND, BOOTSTRAPPER_APPLY_RESTART_NONE, qwEstimatedSize, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS);
777 TestThrowOnFailure(hr, L"Failed to suspend session.");
778
779 // verify that run key was removed
@@ -794,7 +800,7 @@ namespace Bootstrapper
800 this->ValidateRunOnceKeyEntry(cacheExePath);
801
802 // end session
797 - hr = RegistrationSessionEnd(&registration, &cache, &variables, &packages, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, BOOTSTRAPPER_REGISTRATION_TYPE_NONE);
803 + hr = RegistrationSessionEnd(&registration, &cache, &variables, &packages, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, qwEstimatedSize, BOOTSTRAPPER_REGISTRATION_TYPE_NONE);
804 TestThrowOnFailure(hr, L"Failed to unregister bundle.");
805
806 // read resume type after session
src/libs/dutil/WixToolset.DUtil/regutil.cpp
+2 -3
@@ -107,10 +107,9 @@ DAPI_(HRESULT) RegCreate(
107 )
108 {
109 HRESULT hr = S_OK;
110 - DWORD er = ERROR_SUCCESS;
110
112 - er = vpfnRegCreateKeyExW(hkRoot, wzSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, dwAccess, NULL, phk, NULL);
113 - RegExitOnWin32Error(er, hr, "Failed to create registry key.");
111 + hr = RegCreateEx(hkRoot, wzSubKey, dwAccess, REG_KEY_DEFAULT, FALSE, NULL, phk, NULL);
112 + RegExitOnFailure(hr, "Failed to create registry key.");
113
114 LExit:
115 return hr;
src/test/burn/TestBA/TestBA.cs
+17
@@ -27,6 +27,7 @@ namespace WixToolset.Test.BA
27
28 private string updateBundlePath;
29
30 + private bool forceKeepRegistration;
31 private bool immediatelyQuit;
32 private bool quitAfterDetect;
33 private bool explicitlyElevateAndPlanFromOnElevateBegin;
@@ -131,6 +132,12 @@ namespace WixToolset.Test.BA
132 this.explicitlyElevateAndPlanFromOnElevateBegin = false;
133 }
134
135 + string forceKeepRegistration = this.ReadPackageAction(null, "ForceKeepRegistration");
136 + if (String.IsNullOrEmpty(forceKeepRegistration) || !Boolean.TryParse(forceKeepRegistration, out this.forceKeepRegistration))
137 + {
138 + this.forceKeepRegistration = false;
139 + }
140 +
141 string quitAfterDetect = this.ReadPackageAction(null, "QuitAfterDetect");
142 if (String.IsNullOrEmpty(quitAfterDetect) || !Boolean.TryParse(quitAfterDetect, out this.quitAfterDetect))
143 {
@@ -533,6 +540,16 @@ namespace WixToolset.Test.BA
540 this.ShutdownUiThread();
541 }
542
543 + protected override void OnUnregisterBegin(UnregisterBeginEventArgs args)
544 + {
545 + if (this.forceKeepRegistration && args.RegistrationType == RegistrationType.None)
546 + {
547 + args.RegistrationType = RegistrationType.InProgress;
548 + }
549 +
550 + this.Log("OnUnregisterBegin, default: {0}, requested: {1}", args.RecommendedRegistrationType, args.RegistrationType);
551 + }
552 +
553 private void TestVariables()
554 {
555 // First make sure we can check and get standard variables of each type.
src/test/burn/WixTestTools/BundleVerifier.cs
+2 -2
@@ -87,7 +87,7 @@ namespace WixTestTools
87 }
88 }
89
90 - public string VerifyRegisteredAndInPackageCache(int? expectedSystemComponent = null)
90 + public BundleRegistration VerifyRegisteredAndInPackageCache(int? expectedSystemComponent = null)
91 {
92 Assert.True(this.TryGetRegistration(out var registration));
93
@@ -99,7 +99,7 @@ namespace WixTestTools
99 var expectedCachePath = this.GetExpectedCachedBundlePath();
100 WixAssert.StringEqual(expectedCachePath, registration.CachePath, true);
101
102 - return registration.CachePath;
102 + return registration;
103 }
104
105 public void VerifyUnregisteredAndRemovedFromPackageCache()
src/test/burn/WixToolsetTest.BurnE2E/BasicFunctionalityTests.cs
+2 -1
@@ -82,7 +82,8 @@ namespace WixToolsetTest.BurnE2E
82
83 bundle.Install();
84
85 - var cachedBundlePath = bundle.VerifyRegisteredAndInPackageCache();
85 + var registration = bundle.VerifyRegisteredAndInPackageCache();
86 + var cachedBundlePath = registration.CachePath;
87
88 // Source file should be installed
89 Assert.True(File.Exists(packageSourceCodeInstalled), $"Should have found {packageName} payload installed at: {packageSourceCodeInstalled}");
src/test/burn/WixToolsetTest.BurnE2E/CacheTests.cs
+4 -4
@@ -162,14 +162,14 @@ namespace WixToolsetTest.BurnE2E
162 bundleA.Install(bundleACopiedPath);
163 }
164
165 - var bundlePackageCachePath = bundleA.VerifyRegisteredAndInPackageCache();
165 + var bundlePackageRegistration = bundleA.VerifyRegisteredAndInPackageCache();
166
167 packageA.VerifyInstalled(true);
168 packageB.VerifyInstalled(false);
169
170 testBAController.SetPackageRequestedState("PackageB", RequestState.Present);
171
172 - var modifyLogPath = bundleA.Modify(bundlePackageCachePath);
172 + var modifyLogPath = bundleA.Modify(bundlePackageRegistration.CachePath);
173 bundleA.VerifyRegisteredAndInPackageCache();
174
175 packageA.VerifyInstalled(true);
@@ -204,14 +204,14 @@ namespace WixToolsetTest.BurnE2E
204
205 bundleB.Install(bundleBCopiedPath);
206
207 - var bundlePackageCachePath = bundleB.VerifyRegisteredAndInPackageCache();
207 + var bundlePackageRegistration = bundleB.VerifyRegisteredAndInPackageCache();
208
209 packageA.VerifyInstalled(true);
210 packageB.VerifyInstalled(false);
211
212 testBAController.SetPackageRequestedState("PackageB", RequestState.Present);
213
214 - bundleB.Modify(bundlePackageCachePath);
214 + bundleB.Modify(bundlePackageRegistration.CachePath);
215 bundleB.VerifyRegisteredAndInPackageCache();
216
217 packageA.VerifyInstalled(true);
src/test/burn/WixToolsetTest.BurnE2E/MsiTransactionTests.cs
+4 -4
@@ -42,7 +42,7 @@ namespace WixToolsetTest.BurnE2E
42
43 bundleAv1.Install();
44
45 - var bundleAv1CachedPath = bundleAv1.VerifyRegisteredAndInPackageCache();
45 + var bundleAv1Registration = bundleAv1.VerifyRegisteredAndInPackageCache();
46
47 // Source file should be installed
48 Assert.True(File.Exists(packageASourceCodeInstalled), String.Concat("Should have found Package A payload installed at: ", packageASourceCodeInstalled));
@@ -51,7 +51,7 @@ namespace WixToolsetTest.BurnE2E
51
52 bundleAv2.Install();
53
54 - var bundleAv2CachedPath = bundleAv2.VerifyRegisteredAndInPackageCache();
54 + var bundleAv2Registration = bundleAv2.VerifyRegisteredAndInPackageCache();
55
56 // Source file should be upgraded
57 Assert.True(File.Exists(packageDSourceCodeInstalled), String.Concat("Should have found Package D payload installed at: ", packageDSourceCodeInstalled));
@@ -61,7 +61,7 @@ namespace WixToolsetTest.BurnE2E
61 Assert.False(File.Exists(packageBv1SourceCodeInstalled), String.Concat("Package Bv1 payload should have been removed by upgrade uninstall from: ", packageBv1SourceCodeInstalled));
62 Assert.False(File.Exists(packageASourceCodeInstalled), String.Concat("Package A payload should have been removed by upgrade uninstall from: ", packageASourceCodeInstalled));
63
64 - bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache(bundleAv1CachedPath);
64 + bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache(bundleAv1Registration.CachePath);
65
66 // Uninstall everything.
67 bundleAv2.Uninstall();
@@ -71,7 +71,7 @@ namespace WixToolsetTest.BurnE2E
71 Assert.False(File.Exists(packageBv2SourceCodeInstalled), String.Concat("Package Bv2 payload should have been removed by uninstall from: ", packageBv2SourceCodeInstalled));
72 Assert.False(File.Exists(packageCv2SourceCodeInstalled), String.Concat("Package Cv2 payload should have been removed by uninstall from: ", packageCv2SourceCodeInstalled));
73
74 - bundleAv2.VerifyUnregisteredAndRemovedFromPackageCache(bundleAv2CachedPath);
74 + bundleAv2.VerifyUnregisteredAndRemovedFromPackageCache(bundleAv2Registration.CachePath);
75 }
76
77 /// <summary>
src/test/burn/WixToolsetTest.BurnE2E/RegistrationTests.cs
+29
@@ -3,6 +3,7 @@
3 namespace WixToolsetTest.BurnE2E
4 {
5 using System;
6 + using WixToolset.Mba.Core;
7 using Xunit;
8 using Xunit.Abstractions;
9
@@ -10,9 +11,36 @@ namespace WixToolsetTest.BurnE2E
11 {
12 public RegistrationTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { }
13
14 + [Fact]
15 + public void AllowsBAToKeepRegistration()
16 + {
17 + this.CreatePackageInstaller("PackageA");
18 + var bundleA = this.CreateBundleInstaller("BundleA");
19 + var testBAController = this.CreateTestBAController();
20 +
21 + testBAController.SetPackageRequestedState("PackageA", RequestState.Absent);
22 + testBAController.SetForceKeepRegistration();
23 +
24 + bundleA.Install();
25 + var initialRegistration = bundleA.VerifyRegisteredAndInPackageCache();
26 +
27 + Assert.NotNull(initialRegistration.EstimatedSize);
28 +
29 + testBAController.SetForceKeepRegistration(null);
30 + testBAController.ResetPackageStates("PackageA");
31 +
32 + bundleA.Install();
33 + var finalRegistration = bundleA.VerifyRegisteredAndInPackageCache();
34 +
35 + // Verifies https://github.com/wixtoolset/issues/issues/4039
36 + Assert.NotNull(finalRegistration.EstimatedSize);
37 + Assert.InRange(finalRegistration.EstimatedSize.Value, initialRegistration.EstimatedSize.Value + 1, Int32.MaxValue);
38 + }
39 +
40 [Fact]
41 public void AutomaticallyUncachesBundleWhenNotInstalled()
42 {
43 + this.CreatePackageInstaller("PackageA");
44 var bundleA = this.CreateBundleInstaller("BundleA");
45 var testBAController = this.CreateTestBAController();
46
@@ -40,6 +68,7 @@ namespace WixToolsetTest.BurnE2E
68 [Fact]
69 public void RegistersInARPIfPrecached()
70 {
71 + this.CreatePackageInstaller("PackageA");
72 var bundleA = this.CreateBundleInstaller("BundleA");
73
74 bundleA.ManuallyCache();
src/test/burn/WixToolsetTest.BurnE2E/TestBAController.cs
+5
@@ -47,6 +47,11 @@ namespace WixToolsetTest.BurnE2E
47 this.SetBurnTestValue("ExplicitlyElevateAndPlanFromOnElevateBegin", value);
48 }
49
50 + public void SetForceKeepRegistration(string value = "true")
51 + {
52 + this.SetBurnTestValue("ForceKeepRegistration", value);
53 + }
54 +
55 public void SetImmediatelyQuit(string value = "true")
56 {
57 this.SetBurnTestValue("ImmediatelyQuit", value);