From 8dfadd0c9068965af138949b630ef8496b4f7bbb Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Thu, 30 Dec 2021 15:32:57 -0600 Subject: Don't report related operation in OnDetectRelatedBundle. #5796 --- .../WixStdBaTests/BundleA_v10/BundleA_v10.wixproj | 20 +++++++++ .../burn/WixToolset.WixBA/InstallationViewModel.cs | 47 ++++++++++++++-------- src/test/burn/WixToolset.WixBA/RootViewModel.cs | 23 +++++++++++ .../burn/WixToolsetTest.BurnE2E/DependencyTests.cs | 2 +- .../UpgradeRelatedBundleTests.cs | 2 +- 5 files changed, 76 insertions(+), 18 deletions(-) create mode 100644 src/test/burn/TestData/WixStdBaTests/BundleA_v10/BundleA_v10.wixproj (limited to 'src/test') diff --git a/src/test/burn/TestData/WixStdBaTests/BundleA_v10/BundleA_v10.wixproj b/src/test/burn/TestData/WixStdBaTests/BundleA_v10/BundleA_v10.wixproj new file mode 100644 index 00000000..602dc4bc --- /dev/null +++ b/src/test/burn/TestData/WixStdBaTests/BundleA_v10/BundleA_v10.wixproj @@ -0,0 +1,20 @@ + + + + Bundle + hyperlinkLicense + {7D977157-06C9-4176-A931-AC16E18AAB51} + $(DefineConstants);Version=1.0 + WixStdBaTest1_v10 + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/burn/WixToolset.WixBA/InstallationViewModel.cs b/src/test/burn/WixToolset.WixBA/InstallationViewModel.cs index 1846d51b..e056b943 100644 --- a/src/test/burn/WixToolset.WixBA/InstallationViewModel.cs +++ b/src/test/burn/WixToolset.WixBA/InstallationViewModel.cs @@ -19,6 +19,18 @@ namespace WixToolset.WixBA { Absent, Present, + } + + /// + /// The states of upgrade detection. + /// + public enum UpgradeDetectionState + { + // There are no Upgrade related bundles installed. + None, + // All Upgrade related bundles that are installed are older than or the same version as this bundle. + Older, + // At least one Upgrade related bundle is installed that is newer than this bundle. Newer, } @@ -90,7 +102,7 @@ namespace WixToolset.WixBA void RootPropertyChanged(object sender, PropertyChangedEventArgs e) { - if (("DetectState" == e.PropertyName) || ("InstallState" == e.PropertyName)) + if (("DetectState" == e.PropertyName) || ("UpgradeDetectState" == e.PropertyName) || ("InstallState" == e.PropertyName)) { base.OnPropertyChanged("RepairEnabled"); base.OnPropertyChanged("InstallEnabled"); @@ -276,7 +288,9 @@ namespace WixToolset.WixBA { if (this.installCommand == null) { - this.installCommand = new RelayCommand(param => WixBA.Plan(LaunchAction.Install), param => this.root.DetectState == DetectionState.Absent && this.root.InstallState == InstallationState.Waiting); + this.installCommand = new RelayCommand( + param => WixBA.Plan(LaunchAction.Install), + param => this.root.DetectState == DetectionState.Absent && this.root.UpgradeDetectState != UpgradeDetectionState.Newer && this.root.InstallState == InstallationState.Waiting); } return this.installCommand; @@ -399,9 +413,19 @@ namespace WixToolset.WixBA private void DetectedRelatedBundle(object sender, DetectRelatedBundleEventArgs e) { - if (e.Operation == RelatedOperation.Downgrade) + if (e.RelationType == RelationType.Upgrade) { - this.Downgrade = true; + if (WixBA.Model.Engine.CompareVersions(this.Version, e.Version) > 0) + { + if (this.root.UpgradeDetectState == UpgradeDetectionState.None) + { + this.root.UpgradeDetectState = UpgradeDetectionState.Older; + } + } + else + { + this.root.UpgradeDetectState = UpgradeDetectionState.Newer; + } } if (!WixBA.Model.BAManifest.Bundle.Packages.ContainsKey(e.ProductCode)) @@ -432,19 +456,10 @@ namespace WixToolset.WixBA } else if (Hresult.Succeeded(e.Status)) { - if (this.Downgrade) + if (this.root.UpgradeDetectState == UpgradeDetectionState.Newer) { - this.root.DetectState = DetectionState.Newer; - var relatedPackages = WixBA.Model.BAManifest.Bundle.Packages.Values.Where(p => p.Type == PackageType.UpgradeBundle); - var installedVersion = relatedPackages.Any() ? new Version(relatedPackages.Max(p => p.Version)) : null; - if (installedVersion != null && installedVersion < new Version(4, 1) && installedVersion.Build > 10) - { - this.DowngradeMessage = "You must uninstall WiX v" + installedVersion + " before you can install this."; - } - else - { - this.DowngradeMessage = "There is already a newer version of WiX installed on this machine."; - } + this.Downgrade = true; + this.DowngradeMessage = "There is already a newer version of WiX installed on this machine."; } if (LaunchAction.Layout == WixBA.Model.Command.Action) diff --git a/src/test/burn/WixToolset.WixBA/RootViewModel.cs b/src/test/burn/WixToolset.WixBA/RootViewModel.cs index 8cff7274..2dfd214e 100644 --- a/src/test/burn/WixToolset.WixBA/RootViewModel.cs +++ b/src/test/burn/WixToolset.WixBA/RootViewModel.cs @@ -27,6 +27,7 @@ namespace WixToolset.WixBA private bool canceled; private InstallationState installState; private DetectionState detectState; + private UpgradeDetectionState upgradeDetectState; /// /// Creates a new model of the root view. @@ -119,6 +120,28 @@ namespace WixToolset.WixBA } } + /// + /// Gets and sets the upgrade detect state of the view's model. + /// + public UpgradeDetectionState UpgradeDetectState + { + get + { + return this.upgradeDetectState; + } + + set + { + if (this.upgradeDetectState != value) + { + this.upgradeDetectState = value; + + // Notify all the properties derived from the state that the state changed. + base.OnPropertyChanged("UpgradeDetectState"); + } + } + } + /// /// Gets and sets the installation state of the view's model. /// diff --git a/src/test/burn/WixToolsetTest.BurnE2E/DependencyTests.cs b/src/test/burn/WixToolsetTest.BurnE2E/DependencyTests.cs index e2975fc9..309241d9 100644 --- a/src/test/burn/WixToolsetTest.BurnE2E/DependencyTests.cs +++ b/src/test/burn/WixToolsetTest.BurnE2E/DependencyTests.cs @@ -596,7 +596,7 @@ namespace WixToolsetTest.BurnE2E packageDv2.VerifyInstalled(true); Assert.True(LogVerifier.MessageInLogFileRegex(bundleHv2InstallLogFilePath, @"Skipping cross-scope dependency registration on package: PackageA, bundle scope: PerUser, package scope: PerMachine")); - Assert.True(LogVerifier.MessageInLogFileRegex(bundleHv2InstallLogFilePath, @"Detected related bundle: \{[0-9A-Za-z\-]{36}\}, type: Upgrade, scope: PerUser, version: 1\.0\.0\.0, operation: MajorUpgrade, cached: Yes")); + Assert.True(LogVerifier.MessageInLogFileRegex(bundleHv2InstallLogFilePath, @"Detected related bundle: \{[0-9A-Za-z\-]{36}\}, type: Upgrade, scope: PerUser, version: 1\.0\.0\.0, cached: Yes")); bundleHv2.Uninstall(); bundleHv2.VerifyUnregisteredAndRemovedFromPackageCache(); diff --git a/src/test/burn/WixToolsetTest.BurnE2E/UpgradeRelatedBundleTests.cs b/src/test/burn/WixToolsetTest.BurnE2E/UpgradeRelatedBundleTests.cs index 70c0c474..35cc64f0 100644 --- a/src/test/burn/WixToolsetTest.BurnE2E/UpgradeRelatedBundleTests.cs +++ b/src/test/burn/WixToolsetTest.BurnE2E/UpgradeRelatedBundleTests.cs @@ -30,7 +30,7 @@ namespace WixToolsetTest.BurnE2E bundleAv2.VerifyRegisteredAndInPackageCache(); Assert.True(LogVerifier.MessageInLogFileRegex(bundleAv2InstallLogFilePath, @"OnDetectRelatedBundle\(\) - id: \{[0-9A-Za-z\-]{36}\}, missing from cache: True")); - Assert.True(LogVerifier.MessageInLogFileRegex(bundleAv2InstallLogFilePath, @"Detected related bundle: \{[0-9A-Za-z\-]{36}\}, type: Upgrade, scope: PerMachine, version: 1\.0\.0\.0, operation: MajorUpgrade, cached: No")); + Assert.True(LogVerifier.MessageInLogFileRegex(bundleAv2InstallLogFilePath, @"Detected related bundle: \{[0-9A-Za-z\-]{36}\}, type: Upgrade, scope: PerMachine, version: 1\.0\.0\.0, cached: No")); } } } -- cgit v1.2.3-55-g6feb