diff options
author | Rob Mensching <rob@firegiant.com> | 2022-12-21 23:06:05 -0800 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2022-12-22 15:12:23 -0800 |
commit | 8aafcc72550d89cc43dfcb81012abe8576709660 (patch) | |
tree | f4417f9691b3df02ecd2ed237bbb60db91b14974 | |
parent | 34692d57dcc693ec017dda1711f25adbc7759a1c (diff) | |
download | wix-8aafcc72550d89cc43dfcb81012abe8576709660.tar.gz wix-8aafcc72550d89cc43dfcb81012abe8576709660.tar.bz2 wix-8aafcc72550d89cc43dfcb81012abe8576709660.zip |
Register the InstallDate in Burn
Closes 7068
-rw-r--r-- | src/burn/engine/registration.cpp | 13 | ||||
-rw-r--r-- | src/burn/test/BurnUnitTest/RegistrationTest.cpp | 2 | ||||
-rw-r--r-- | src/test/burn/WixTestTools/GenericArpRegistration.cs | 4 | ||||
-rw-r--r-- | src/test/burn/WixToolsetTest.BurnE2E/RegistrationTests.cs | 7 |
4 files changed, 24 insertions, 2 deletions
diff --git a/src/burn/engine/registration.cpp b/src/burn/engine/registration.cpp index 0117a993..01ed30d7 100644 --- a/src/burn/engine/registration.cpp +++ b/src/burn/engine/registration.cpp | |||
@@ -10,6 +10,7 @@ const LPCWSTR REGISTRY_RUN_ONCE_KEY = L"SOFTWARE\\Microsoft\\Windows\\CurrentVer | |||
10 | const LPCWSTR REGISTRY_BUNDLE_DISPLAY_ICON = L"DisplayIcon"; | 10 | const LPCWSTR REGISTRY_BUNDLE_DISPLAY_ICON = L"DisplayIcon"; |
11 | const LPCWSTR REGISTRY_BUNDLE_DISPLAY_VERSION = L"DisplayVersion"; | 11 | const LPCWSTR REGISTRY_BUNDLE_DISPLAY_VERSION = L"DisplayVersion"; |
12 | const LPCWSTR REGISTRY_BUNDLE_ESTIMATED_SIZE = L"EstimatedSize"; | 12 | const LPCWSTR REGISTRY_BUNDLE_ESTIMATED_SIZE = L"EstimatedSize"; |
13 | const LPCWSTR REGISTRY_BUNDLE_INSTALL_DATE = L"InstallDate"; | ||
13 | const LPCWSTR REGISTRY_BUNDLE_PUBLISHER = L"Publisher"; | 14 | const LPCWSTR REGISTRY_BUNDLE_PUBLISHER = L"Publisher"; |
14 | const LPCWSTR REGISTRY_BUNDLE_HELP_LINK = L"HelpLink"; | 15 | const LPCWSTR REGISTRY_BUNDLE_HELP_LINK = L"HelpLink"; |
15 | const LPCWSTR REGISTRY_BUNDLE_HELP_TELEPHONE = L"HelpTelephone"; | 16 | const LPCWSTR REGISTRY_BUNDLE_HELP_TELEPHONE = L"HelpTelephone"; |
@@ -610,6 +611,7 @@ extern "C" HRESULT RegistrationSessionBegin( | |||
610 | HKEY hkRegistration = NULL; | 611 | HKEY hkRegistration = NULL; |
611 | BOOL fCreated = FALSE; | 612 | BOOL fCreated = FALSE; |
612 | LPWSTR sczPublisher = NULL; | 613 | LPWSTR sczPublisher = NULL; |
614 | SYSTEMTIME systime = { }; | ||
613 | DWORD er = ERROR_SUCCESS; | 615 | DWORD er = ERROR_SUCCESS; |
614 | 616 | ||
615 | AssertSz(BOOTSTRAPPER_REGISTRATION_TYPE_NONE != registrationType, "Registration type can't be NONE"); | 617 | AssertSz(BOOTSTRAPPER_REGISTRATION_TYPE_NONE != registrationType, "Registration type can't be NONE"); |
@@ -814,10 +816,17 @@ extern "C" HRESULT RegistrationSessionBegin( | |||
814 | ExitOnFailure(hr, "Failed to write update registration."); | 816 | ExitOnFailure(hr, "Failed to write update registration."); |
815 | } | 817 | } |
816 | 818 | ||
817 | // Only set estimated size here for the first time. | 819 | // Only set install date and initial estimated size here for the first time. |
818 | // It will always get updated at the end of the session. | 820 | // Estimated size will always get updated at the end of the session. |
819 | if (fCreated) | 821 | if (fCreated) |
820 | { | 822 | { |
823 | // Write the install date. | ||
824 | ::GetLocalTime(&systime); | ||
825 | |||
826 | hr = RegWriteStringFormatted(hkRegistration, REGISTRY_BUNDLE_INSTALL_DATE, L"%04u%02u%02u", systime.wYear, systime.wMonth, systime.wDay); | ||
827 | ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_INSTALL_DATE); | ||
828 | |||
829 | // Write the initial estimated size. | ||
821 | hr = UpdateEstimatedSize(hkRegistration, qwEstimatedSize); | 830 | hr = UpdateEstimatedSize(hkRegistration, qwEstimatedSize); |
822 | ExitOnFailure(hr, "Failed to update estimated size."); | 831 | ExitOnFailure(hr, "Failed to update estimated size."); |
823 | } | 832 | } |
diff --git a/src/burn/test/BurnUnitTest/RegistrationTest.cpp b/src/burn/test/BurnUnitTest/RegistrationTest.cpp index f95c011f..fc84511d 100644 --- a/src/burn/test/BurnUnitTest/RegistrationTest.cpp +++ b/src/burn/test/BurnUnitTest/RegistrationTest.cpp | |||
@@ -111,6 +111,7 @@ namespace Bootstrapper | |||
111 | Assert::True(Directory::Exists(cacheDirectory), "Cache directory didn't exist."); | 111 | Assert::True(Directory::Exists(cacheDirectory), "Cache directory didn't exist."); |
112 | Assert::True(File::Exists(Path::Combine(cacheDirectory, gcnew String(L"setup.exe"))), "Bundle exe wasn't cached."); | 112 | Assert::True(File::Exists(Path::Combine(cacheDirectory, gcnew String(L"setup.exe"))), "Bundle exe wasn't cached."); |
113 | 113 | ||
114 | this->ValidateUninstallKeyString(L"InstallDate", DateTime::Now.ToString("yyyyMMdd")); | ||
114 | this->ValidateUninstallKeyResume(Int32(BURN_RESUME_MODE_ACTIVE)); | 115 | this->ValidateUninstallKeyResume(Int32(BURN_RESUME_MODE_ACTIVE)); |
115 | this->ValidateRunOnceKeyEntry(cacheExePath); | 116 | this->ValidateRunOnceKeyEntry(cacheExePath); |
116 | 117 | ||
@@ -121,6 +122,7 @@ namespace Bootstrapper | |||
121 | // verify that registration was removed | 122 | // verify that registration was removed |
122 | Assert::False(Directory::Exists(cacheDirectory), "Cache directory wasn't removed."); | 123 | Assert::False(Directory::Exists(cacheDirectory), "Cache directory wasn't removed."); |
123 | 124 | ||
125 | this->ValidateUninstallKeyNull(L"InstallDate"); | ||
124 | this->ValidateUninstallKeyNull(L"Resume"); | 126 | this->ValidateUninstallKeyNull(L"Resume"); |
125 | this->ValidateRunOnceKeyString(TEST_BUNDLE_ID, nullptr); | 127 | this->ValidateRunOnceKeyString(TEST_BUNDLE_ID, nullptr); |
126 | } | 128 | } |
diff --git a/src/test/burn/WixTestTools/GenericArpRegistration.cs b/src/test/burn/WixTestTools/GenericArpRegistration.cs index d87c4feb..dfddd9a3 100644 --- a/src/test/burn/WixTestTools/GenericArpRegistration.cs +++ b/src/test/burn/WixTestTools/GenericArpRegistration.cs | |||
@@ -15,6 +15,7 @@ namespace WixTestTools | |||
15 | public const string REGISTRY_ARP_DISPLAY_NAME = "DisplayName"; | 15 | public const string REGISTRY_ARP_DISPLAY_NAME = "DisplayName"; |
16 | public const string REGISTRY_ARP_DISPLAY_VERSION = "DisplayVersion"; | 16 | public const string REGISTRY_ARP_DISPLAY_VERSION = "DisplayVersion"; |
17 | public const string REGISTRY_ARP_ESTIMATED_SIZE = "EstimatedSize"; | 17 | public const string REGISTRY_ARP_ESTIMATED_SIZE = "EstimatedSize"; |
18 | public const string REGISTRY_ARP_INSTALL_DATE = "InstallDate"; | ||
18 | public const string REGISTRY_ARP_PUBLISHER = "Publisher"; | 19 | public const string REGISTRY_ARP_PUBLISHER = "Publisher"; |
19 | public const string REGISTRY_ARP_HELP_LINK = "HelpLink"; | 20 | public const string REGISTRY_ARP_HELP_LINK = "HelpLink"; |
20 | public const string REGISTRY_ARP_HELP_TELEPHONE = "HelpTelephone"; | 21 | public const string REGISTRY_ARP_HELP_TELEPHONE = "HelpTelephone"; |
@@ -42,6 +43,8 @@ namespace WixTestTools | |||
42 | 43 | ||
43 | public int? EstimatedSize { get; set; } | 44 | public int? EstimatedSize { get; set; } |
44 | 45 | ||
46 | public string InstallDate { get; set; } | ||
47 | |||
45 | public int? Installed { get; set; } | 48 | public int? Installed { get; set; } |
46 | 49 | ||
47 | public string ModifyPath { get; set; } | 50 | public string ModifyPath { get; set; } |
@@ -103,6 +106,7 @@ namespace WixTestTools | |||
103 | registration.DisplayName = idKey.GetValue(REGISTRY_ARP_DISPLAY_NAME) as string; | 106 | registration.DisplayName = idKey.GetValue(REGISTRY_ARP_DISPLAY_NAME) as string; |
104 | registration.DisplayVersion = idKey.GetValue(REGISTRY_ARP_DISPLAY_VERSION) as string; | 107 | registration.DisplayVersion = idKey.GetValue(REGISTRY_ARP_DISPLAY_VERSION) as string; |
105 | registration.EstimatedSize = idKey.GetValue(REGISTRY_ARP_ESTIMATED_SIZE) as int?; | 108 | registration.EstimatedSize = idKey.GetValue(REGISTRY_ARP_ESTIMATED_SIZE) as int?; |
109 | registration.InstallDate = idKey.GetValue(REGISTRY_ARP_INSTALL_DATE) as string; | ||
106 | registration.Installed = idKey.GetValue(REGISTRY_ARP_INSTALLED) as int?; | 110 | registration.Installed = idKey.GetValue(REGISTRY_ARP_INSTALLED) as int?; |
107 | registration.ModifyPath = idKey.GetValue(REGISTRY_ARP_MODIFY_PATH) as string; | 111 | registration.ModifyPath = idKey.GetValue(REGISTRY_ARP_MODIFY_PATH) as string; |
108 | registration.Publisher = idKey.GetValue(REGISTRY_ARP_PUBLISHER) as string; | 112 | registration.Publisher = idKey.GetValue(REGISTRY_ARP_PUBLISHER) as string; |
diff --git a/src/test/burn/WixToolsetTest.BurnE2E/RegistrationTests.cs b/src/test/burn/WixToolsetTest.BurnE2E/RegistrationTests.cs index b45ec83a..d9eb36ba 100644 --- a/src/test/burn/WixToolsetTest.BurnE2E/RegistrationTests.cs +++ b/src/test/burn/WixToolsetTest.BurnE2E/RegistrationTests.cs | |||
@@ -25,7 +25,12 @@ namespace WixToolsetTest.BurnE2E | |||
25 | bundleA.Install(); | 25 | bundleA.Install(); |
26 | var initialRegistration = bundleA.VerifyRegisteredAndInPackageCache(); | 26 | var initialRegistration = bundleA.VerifyRegisteredAndInPackageCache(); |
27 | 27 | ||
28 | var now = DateTime.Now; | ||
29 | var today = now.ToString("yyyyMMdd"); | ||
30 | var yesterday = now.AddDays(-1).ToString("yyyyMMdd"); // check yesterday in case the bundle install crossed the midnight hour. | ||
31 | |||
28 | Assert.NotNull(initialRegistration.EstimatedSize); | 32 | Assert.NotNull(initialRegistration.EstimatedSize); |
33 | Assert.True(initialRegistration.InstallDate == today || initialRegistration.InstallDate == yesterday, $"Installed date should have been {today} or {yesterday}"); | ||
29 | 34 | ||
30 | testBAController.SetForceKeepRegistration(null); | 35 | testBAController.SetForceKeepRegistration(null); |
31 | testBAController.ResetPackageStates("PackageA"); | 36 | testBAController.ResetPackageStates("PackageA"); |
@@ -36,6 +41,8 @@ namespace WixToolsetTest.BurnE2E | |||
36 | // Verifies https://github.com/wixtoolset/issues/issues/4039 | 41 | // Verifies https://github.com/wixtoolset/issues/issues/4039 |
37 | Assert.NotNull(finalRegistration.EstimatedSize); | 42 | Assert.NotNull(finalRegistration.EstimatedSize); |
38 | Assert.InRange(finalRegistration.EstimatedSize.Value, initialRegistration.EstimatedSize.Value + 1, Int32.MaxValue); | 43 | Assert.InRange(finalRegistration.EstimatedSize.Value, initialRegistration.EstimatedSize.Value + 1, Int32.MaxValue); |
44 | |||
45 | Assert.Equal(initialRegistration.InstallDate, finalRegistration.InstallDate); | ||
39 | } | 46 | } |
40 | 47 | ||
41 | [RuntimeFact] | 48 | [RuntimeFact] |