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 --- .../inc/BootstrapperApplication.h | 1 - .../WixToolset.Mba.Core/BootstrapperApplication.cs | 4 +- src/api/burn/WixToolset.Mba.Core/EventArgs.cs | 8 +--- .../IBootstrapperApplication.cs | 15 ------- src/api/burn/balutil/inc/BalBaseBAFunctions.h | 1 - .../balutil/inc/BalBaseBootstrapperApplication.h | 1 - .../inc/BalBaseBootstrapperApplicationProc.h | 2 +- .../burn/balutil/inc/IBootstrapperApplication.h | 1 - src/burn/engine/core.cpp | 2 +- src/burn/engine/detect.cpp | 52 +--------------------- src/burn/engine/detect.h | 1 - src/burn/engine/engine.mc | 2 +- src/burn/engine/userexperience.cpp | 4 +- src/burn/engine/userexperience.h | 1 - .../WixStandardBootstrapperApplication.cpp | 13 ++++-- .../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 +- 20 files changed, 94 insertions(+), 108 deletions(-) create mode 100644 src/test/burn/TestData/WixStdBaTests/BundleA_v10/BundleA_v10.wixproj diff --git a/src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h b/src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h index c2641b5f..4fbfc890 100644 --- a/src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h +++ b/src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h @@ -725,7 +725,6 @@ struct BA_ONDETECTRELATEDBUNDLE_ARGS LPCWSTR wzBundleTag; BOOL fPerMachine; LPCWSTR wzVersion; - BOOTSTRAPPER_RELATED_OPERATION operation; BOOL fMissingFromCache; }; diff --git a/src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs b/src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs index b1fcaea4..34b63a50 100644 --- a/src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs +++ b/src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs @@ -1345,9 +1345,9 @@ namespace WixToolset.Mba.Core return args.HResult; } - int IBootstrapperApplication.OnDetectRelatedBundle(string wzProductCode, RelationType relationType, string wzBundleTag, bool fPerMachine, string wzVersion, RelatedOperation operation, bool fMissingFromCache, ref bool fCancel) + int IBootstrapperApplication.OnDetectRelatedBundle(string wzProductCode, RelationType relationType, string wzBundleTag, bool fPerMachine, string wzVersion, bool fMissingFromCache, ref bool fCancel) { - DetectRelatedBundleEventArgs args = new DetectRelatedBundleEventArgs(wzProductCode, relationType, wzBundleTag, fPerMachine, wzVersion, operation, fMissingFromCache, fCancel); + DetectRelatedBundleEventArgs args = new DetectRelatedBundleEventArgs(wzProductCode, relationType, wzBundleTag, fPerMachine, wzVersion, fMissingFromCache, fCancel); this.OnDetectRelatedBundle(args); fCancel = args.Cancel; diff --git a/src/api/burn/WixToolset.Mba.Core/EventArgs.cs b/src/api/burn/WixToolset.Mba.Core/EventArgs.cs index 65169b25..93831be6 100644 --- a/src/api/burn/WixToolset.Mba.Core/EventArgs.cs +++ b/src/api/burn/WixToolset.Mba.Core/EventArgs.cs @@ -434,7 +434,7 @@ namespace WixToolset.Mba.Core public class DetectRelatedBundleEventArgs : CancellableHResultEventArgs { /// - public DetectRelatedBundleEventArgs(string productCode, RelationType relationType, string bundleTag, bool perMachine, string version, RelatedOperation operation, bool missingFromCache, bool cancelRecommendation) + public DetectRelatedBundleEventArgs(string productCode, RelationType relationType, string bundleTag, bool perMachine, string version, bool missingFromCache, bool cancelRecommendation) : base(cancelRecommendation) { this.ProductCode = productCode; @@ -442,7 +442,6 @@ namespace WixToolset.Mba.Core this.BundleTag = bundleTag; this.PerMachine = perMachine; this.Version = version; - this.Operation = operation; this.MissingFromCache = missingFromCache; } @@ -471,11 +470,6 @@ namespace WixToolset.Mba.Core /// public string Version { get; private set; } - /// - /// Gets the operation that will be taken on the detected bundle. - /// - public RelatedOperation Operation { get; private set; } - /// /// Whether the related bundle is missing from the package cache. /// diff --git a/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplication.cs b/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplication.cs index 3df54bde..babd523a 100644 --- a/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplication.cs +++ b/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplication.cs @@ -156,15 +156,6 @@ namespace WixToolset.Mba.Core /// /// See . /// - /// - /// - /// - /// - /// - /// - /// - /// - /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnDetectRelatedBundle( @@ -173,7 +164,6 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.LPWStr)] string wzBundleTag, [MarshalAs(UnmanagedType.Bool)] bool fPerMachine, [MarshalAs(UnmanagedType.LPWStr)] string wzVersion, - [MarshalAs(UnmanagedType.U4)] RelatedOperation operation, [MarshalAs(UnmanagedType.Bool)] bool fMissingFromCache, [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); @@ -289,11 +279,6 @@ namespace WixToolset.Mba.Core /// /// See . /// - /// - /// - /// - /// - /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnPlanRelatedBundle( diff --git a/src/api/burn/balutil/inc/BalBaseBAFunctions.h b/src/api/burn/balutil/inc/BalBaseBAFunctions.h index 7f52f76e..22e16f1b 100644 --- a/src/api/burn/balutil/inc/BalBaseBAFunctions.h +++ b/src/api/burn/balutil/inc/BalBaseBAFunctions.h @@ -167,7 +167,6 @@ public: // IBootstrapperApplication __in_z LPCWSTR /*wzBundleTag*/, __in BOOL /*fPerMachine*/, __in LPCWSTR /*wzVersion*/, - __in BOOTSTRAPPER_RELATED_OPERATION /*operation*/, __in BOOL /*fMissingFromCache*/, __inout BOOL* /*pfCancel*/ ) diff --git a/src/api/burn/balutil/inc/BalBaseBootstrapperApplication.h b/src/api/burn/balutil/inc/BalBaseBootstrapperApplication.h index 5665fee3..631d3c62 100644 --- a/src/api/burn/balutil/inc/BalBaseBootstrapperApplication.h +++ b/src/api/burn/balutil/inc/BalBaseBootstrapperApplication.h @@ -172,7 +172,6 @@ public: // IBootstrapperApplication __in_z LPCWSTR /*wzBundleTag*/, __in BOOL /*fPerMachine*/, __in LPCWSTR /*wzVersion*/, - __in BOOTSTRAPPER_RELATED_OPERATION /*operation*/, __in BOOL /*fMissingFromCache*/, __inout BOOL* pfCancel ) diff --git a/src/api/burn/balutil/inc/BalBaseBootstrapperApplicationProc.h b/src/api/burn/balutil/inc/BalBaseBootstrapperApplicationProc.h index 2292cd64..b9866e4b 100644 --- a/src/api/burn/balutil/inc/BalBaseBootstrapperApplicationProc.h +++ b/src/api/burn/balutil/inc/BalBaseBootstrapperApplicationProc.h @@ -114,7 +114,7 @@ static HRESULT BalBaseBAProcOnDetectRelatedBundle( __inout BA_ONDETECTRELATEDBUNDLE_RESULTS* pResults ) { - return pBA->OnDetectRelatedBundle(pArgs->wzBundleId, pArgs->relationType, pArgs->wzBundleTag, pArgs->fPerMachine, pArgs->wzVersion, pArgs->operation, pArgs->fMissingFromCache, &pResults->fCancel); + return pBA->OnDetectRelatedBundle(pArgs->wzBundleId, pArgs->relationType, pArgs->wzBundleTag, pArgs->fPerMachine, pArgs->wzVersion, pArgs->fMissingFromCache, &pResults->fCancel); } static HRESULT BalBaseBAProcOnDetectPackageBegin( diff --git a/src/api/burn/balutil/inc/IBootstrapperApplication.h b/src/api/burn/balutil/inc/IBootstrapperApplication.h index 2ba1f503..577a705b 100644 --- a/src/api/burn/balutil/inc/IBootstrapperApplication.h +++ b/src/api/burn/balutil/inc/IBootstrapperApplication.h @@ -91,7 +91,6 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A __in_z LPCWSTR wzBundleTag, __in BOOL fPerMachine, __in_z LPCWSTR wzVersion, - __in BOOTSTRAPPER_RELATED_OPERATION operation, __in BOOL fMissingFromCache, __inout BOOL* pfCancel ) = 0; diff --git a/src/burn/engine/core.cpp b/src/burn/engine/core.cpp index 96845655..30c64b01 100644 --- a/src/burn/engine/core.cpp +++ b/src/burn/engine/core.cpp @@ -359,7 +359,7 @@ extern "C" HRESULT CoreDetect( ExitOnFailure(hr, "Failed to detect provider key bundle id."); // Report the related bundles. - hr = DetectReportRelatedBundles(&pEngineState->userExperience, &pEngineState->registration, pEngineState->command.relationType, pEngineState->command.action, &pEngineState->registration.fEligibleForCleanup); + hr = DetectReportRelatedBundles(&pEngineState->userExperience, &pEngineState->registration, pEngineState->command.relationType, &pEngineState->registration.fEligibleForCleanup); ExitOnFailure(hr, "Failed to report detected related bundles."); // Do update detection. diff --git a/src/burn/engine/detect.cpp b/src/burn/engine/detect.cpp index 4eda240e..be828366 100644 --- a/src/burn/engine/detect.cpp +++ b/src/burn/engine/detect.cpp @@ -154,68 +154,20 @@ extern "C" HRESULT DetectReportRelatedBundles( __in BURN_USER_EXPERIENCE* pUX, __in BURN_REGISTRATION* pRegistration, __in BOOTSTRAPPER_RELATION_TYPE relationType, - __in BOOTSTRAPPER_ACTION action, __out BOOL* pfEligibleForCleanup ) { HRESULT hr = S_OK; - int nCompareResult = 0; BOOTSTRAPPER_REQUEST_STATE uninstallRequestState = BOOTSTRAPPER_REQUEST_STATE_NONE; *pfEligibleForCleanup = pRegistration->fInstalled || pRegistration->fCached; for (DWORD iRelatedBundle = 0; iRelatedBundle < pRegistration->relatedBundles.cRelatedBundles; ++iRelatedBundle) { const BURN_RELATED_BUNDLE* pRelatedBundle = pRegistration->relatedBundles.rgRelatedBundles + iRelatedBundle; - BOOTSTRAPPER_RELATED_OPERATION operation = BOOTSTRAPPER_RELATED_OPERATION_NONE; - - switch (pRelatedBundle->relationType) - { - case BOOTSTRAPPER_RELATION_UPGRADE: - if (BOOTSTRAPPER_RELATION_UPGRADE != relationType && BOOTSTRAPPER_ACTION_UNINSTALL < action) - { - hr = VerCompareParsedVersions(pRegistration->pVersion, pRelatedBundle->pVersion, &nCompareResult); - ExitOnFailure(hr, "Failed to compare bundle version '%ls' to related bundle version '%ls'", pRegistration->pVersion->sczVersion, pRelatedBundle->pVersion->sczVersion); - - if (nCompareResult < 0) - { - operation = BOOTSTRAPPER_RELATED_OPERATION_DOWNGRADE; - } - else - { - operation = BOOTSTRAPPER_RELATED_OPERATION_MAJOR_UPGRADE; - } - } - break; - - case BOOTSTRAPPER_RELATION_PATCH: __fallthrough; - case BOOTSTRAPPER_RELATION_ADDON: - if (BOOTSTRAPPER_ACTION_UNINSTALL == action) - { - operation = BOOTSTRAPPER_RELATED_OPERATION_REMOVE; - } - else if (BOOTSTRAPPER_ACTION_INSTALL == action || BOOTSTRAPPER_ACTION_MODIFY == action) - { - operation = BOOTSTRAPPER_RELATED_OPERATION_INSTALL; - } - else if (BOOTSTRAPPER_ACTION_REPAIR == action) - { - operation = BOOTSTRAPPER_RELATED_OPERATION_REPAIR; - } - break; - - case BOOTSTRAPPER_RELATION_DETECT: __fallthrough; - case BOOTSTRAPPER_RELATION_DEPENDENT: - break; - - default: - hr = E_FAIL; - ExitOnRootFailure(hr, "Unexpected relation type encountered: %d", pRelatedBundle->relationType); - break; - } - LogId(REPORT_STANDARD, MSG_DETECTED_RELATED_BUNDLE, pRelatedBundle->package.sczId, LoggingRelationTypeToString(pRelatedBundle->relationType), LoggingPerMachineToString(pRelatedBundle->package.fPerMachine), pRelatedBundle->pVersion->sczVersion, LoggingRelatedOperationToString(operation), LoggingBoolToString(pRelatedBundle->package.fCached)); + LogId(REPORT_STANDARD, MSG_DETECTED_RELATED_BUNDLE, pRelatedBundle->package.sczId, LoggingRelationTypeToString(pRelatedBundle->relationType), LoggingPerMachineToString(pRelatedBundle->package.fPerMachine), pRelatedBundle->pVersion->sczVersion, LoggingBoolToString(pRelatedBundle->package.fCached)); - hr = UserExperienceOnDetectRelatedBundle(pUX, pRelatedBundle->package.sczId, pRelatedBundle->relationType, pRelatedBundle->sczTag, pRelatedBundle->package.fPerMachine, pRelatedBundle->pVersion, operation, !pRelatedBundle->package.fCached); + hr = UserExperienceOnDetectRelatedBundle(pUX, pRelatedBundle->package.sczId, pRelatedBundle->relationType, pRelatedBundle->sczTag, pRelatedBundle->package.fPerMachine, pRelatedBundle->pVersion, !pRelatedBundle->package.fCached); ExitOnRootFailure(hr, "BA aborted detect related bundle."); // For now, if any related bundles will be executed during uninstall by default then never automatically clean up the bundle. diff --git a/src/burn/engine/detect.h b/src/burn/engine/detect.h index 9bc34882..cdca2777 100644 --- a/src/burn/engine/detect.h +++ b/src/burn/engine/detect.h @@ -29,7 +29,6 @@ HRESULT DetectReportRelatedBundles( __in BURN_USER_EXPERIENCE* pUX, __in BURN_REGISTRATION* pRegistration, __in BOOTSTRAPPER_RELATION_TYPE relationType, - __in BOOTSTRAPPER_ACTION action, __out BOOL* pfEligibleForCleanup ); diff --git a/src/burn/engine/engine.mc b/src/burn/engine/engine.mc index dde4d40b..5c1b0b69 100644 --- a/src/burn/engine/engine.mc +++ b/src/burn/engine/engine.mc @@ -223,7 +223,7 @@ MessageId=102 Severity=Success SymbolicName=MSG_DETECTED_RELATED_BUNDLE Language=English -Detected related bundle: %1!ls!, type: %2!hs!, scope: %3!hs!, version: %4!ls!, operation: %5!hs!, cached: %6!hs! +Detected related bundle: %1!ls!, type: %2!hs!, scope: %3!hs!, version: %4!ls!, cached: %5!hs! . MessageId=103 diff --git a/src/burn/engine/userexperience.cpp b/src/burn/engine/userexperience.cpp index ee22a318..6ea16905 100644 --- a/src/burn/engine/userexperience.cpp +++ b/src/burn/engine/userexperience.cpp @@ -104,7 +104,7 @@ extern "C" HRESULT UserExperienceLoad( args.pCommand = pCommand; args.pfnBootstrapperEngineProc = EngineForApplicationProc; args.pvBootstrapperEngineProcContext = pEngineContext; - args.qwEngineAPIVersion = MAKEQWORDVERSION(2021, 12, 7, 0); + args.qwEngineAPIVersion = MAKEQWORDVERSION(2021, 12, 30, 0); results.cbSize = sizeof(BOOTSTRAPPER_CREATE_RESULTS); @@ -1164,7 +1164,6 @@ EXTERN_C BAAPI UserExperienceOnDetectRelatedBundle( __in_z LPCWSTR wzBundleTag, __in BOOL fPerMachine, __in VERUTIL_VERSION* pVersion, - __in BOOTSTRAPPER_RELATED_OPERATION operation, __in BOOL fMissingFromCache ) { @@ -1178,7 +1177,6 @@ EXTERN_C BAAPI UserExperienceOnDetectRelatedBundle( args.wzBundleTag = wzBundleTag; args.fPerMachine = fPerMachine; args.wzVersion = pVersion->sczVersion; - args.operation = operation; args.fMissingFromCache = fMissingFromCache; results.cbSize = sizeof(results); diff --git a/src/burn/engine/userexperience.h b/src/burn/engine/userexperience.h index 27d0a1e3..e4c5d3ee 100644 --- a/src/burn/engine/userexperience.h +++ b/src/burn/engine/userexperience.h @@ -286,7 +286,6 @@ BAAPI UserExperienceOnDetectRelatedBundle( __in_z LPCWSTR wzBundleTag, __in BOOL fPerMachine, __in VERUTIL_VERSION* pVersion, - __in BOOTSTRAPPER_RELATED_OPERATION operation, __in BOOL fMissingFromCache ); BAAPI UserExperienceOnDetectRelatedMsiPackage( diff --git a/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp b/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp index ec3c268a..7b70d772 100644 --- a/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp +++ b/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp @@ -246,12 +246,12 @@ public: // IBootstrapperApplication __in LPCWSTR wzBundleTag, __in BOOL fPerMachine, __in LPCWSTR wzVersion, - __in BOOTSTRAPPER_RELATED_OPERATION operation, __in BOOL fMissingFromCache, __inout BOOL* pfCancel ) { BAL_INFO_PACKAGE* pPackage = NULL; + int nCompare = 0; if (!fMissingFromCache) { @@ -261,14 +261,15 @@ 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) + if (!m_fPrereq && BOOTSTRAPPER_RELATION_UPGRADE == relationType && + SUCCEEDED(m_pEngine->CompareVersions(m_sczBundleVersion, wzVersion, &nCompare)) && 0 > nCompare) { BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "A newer version (v%ls) of this product is installed.", wzVersion); m_fDowngrading = TRUE; } } - return CBalBaseBootstrapperApplication::OnDetectRelatedBundle(wzBundleId, relationType, wzBundleTag, fPerMachine, wzVersion, operation, fMissingFromCache, pfCancel); + return CBalBaseBootstrapperApplication::OnDetectRelatedBundle(wzBundleId, relationType, wzBundleTag, fPerMachine, wzVersion, fMissingFromCache, pfCancel); } @@ -2091,7 +2092,8 @@ public: //CBalBaseBootstrapperApplication } } - hr = S_OK; + hr = BalGetStringVariable(L"WixBundleVersion", &m_sczBundleVersion); + BalExitOnFailure(hr, "CWixStandardBootstrapperApplication initialization failed."); LExit: return hr; @@ -4129,6 +4131,7 @@ public: m_plannedAction = BOOTSTRAPPER_ACTION_UNKNOWN; m_sczAfterForcedRestartPackage = NULL; + m_sczBundleVersion = NULL; m_pWixLoc = NULL; m_Bundle = { }; @@ -4367,6 +4370,7 @@ public: ReleaseStr(m_sczLanguage); ReleaseStr(m_sczLicenseFile); ReleaseStr(m_sczLicenseUrl); + ReleaseStr(m_sczBundleVersion); ReleaseStr(m_sczAfterForcedRestartPackage); ReleaseNullObject(m_pEngine); @@ -4391,6 +4395,7 @@ private: BOOTSTRAPPER_ACTION m_plannedAction; LPWSTR m_sczAfterForcedRestartPackage; + LPWSTR m_sczBundleVersion; WIX_LOCALIZATION* m_pWixLoc; BAL_INFO_BUNDLE m_Bundle; 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