aboutsummaryrefslogtreecommitdiff
path: root/src/test/burn/WixToolset.WixBA/InstallationViewModel.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/burn/WixToolset.WixBA/InstallationViewModel.cs')
-rw-r--r--src/test/burn/WixToolset.WixBA/InstallationViewModel.cs47
1 files changed, 31 insertions, 16 deletions
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
19 { 19 {
20 Absent, 20 Absent,
21 Present, 21 Present,
22 }
23
24 /// <summary>
25 /// The states of upgrade detection.
26 /// </summary>
27 public enum UpgradeDetectionState
28 {
29 // There are no Upgrade related bundles installed.
30 None,
31 // All Upgrade related bundles that are installed are older than or the same version as this bundle.
32 Older,
33 // At least one Upgrade related bundle is installed that is newer than this bundle.
22 Newer, 34 Newer,
23 } 35 }
24 36
@@ -90,7 +102,7 @@ namespace WixToolset.WixBA
90 102
91 void RootPropertyChanged(object sender, PropertyChangedEventArgs e) 103 void RootPropertyChanged(object sender, PropertyChangedEventArgs e)
92 { 104 {
93 if (("DetectState" == e.PropertyName) || ("InstallState" == e.PropertyName)) 105 if (("DetectState" == e.PropertyName) || ("UpgradeDetectState" == e.PropertyName) || ("InstallState" == e.PropertyName))
94 { 106 {
95 base.OnPropertyChanged("RepairEnabled"); 107 base.OnPropertyChanged("RepairEnabled");
96 base.OnPropertyChanged("InstallEnabled"); 108 base.OnPropertyChanged("InstallEnabled");
@@ -276,7 +288,9 @@ namespace WixToolset.WixBA
276 { 288 {
277 if (this.installCommand == null) 289 if (this.installCommand == null)
278 { 290 {
279 this.installCommand = new RelayCommand(param => WixBA.Plan(LaunchAction.Install), param => this.root.DetectState == DetectionState.Absent && this.root.InstallState == InstallationState.Waiting); 291 this.installCommand = new RelayCommand(
292 param => WixBA.Plan(LaunchAction.Install),
293 param => this.root.DetectState == DetectionState.Absent && this.root.UpgradeDetectState != UpgradeDetectionState.Newer && this.root.InstallState == InstallationState.Waiting);
280 } 294 }
281 295
282 return this.installCommand; 296 return this.installCommand;
@@ -399,9 +413,19 @@ namespace WixToolset.WixBA
399 413
400 private void DetectedRelatedBundle(object sender, DetectRelatedBundleEventArgs e) 414 private void DetectedRelatedBundle(object sender, DetectRelatedBundleEventArgs e)
401 { 415 {
402 if (e.Operation == RelatedOperation.Downgrade) 416 if (e.RelationType == RelationType.Upgrade)
403 { 417 {
404 this.Downgrade = true; 418 if (WixBA.Model.Engine.CompareVersions(this.Version, e.Version) > 0)
419 {
420 if (this.root.UpgradeDetectState == UpgradeDetectionState.None)
421 {
422 this.root.UpgradeDetectState = UpgradeDetectionState.Older;
423 }
424 }
425 else
426 {
427 this.root.UpgradeDetectState = UpgradeDetectionState.Newer;
428 }
405 } 429 }
406 430
407 if (!WixBA.Model.BAManifest.Bundle.Packages.ContainsKey(e.ProductCode)) 431 if (!WixBA.Model.BAManifest.Bundle.Packages.ContainsKey(e.ProductCode))
@@ -432,19 +456,10 @@ namespace WixToolset.WixBA
432 } 456 }
433 else if (Hresult.Succeeded(e.Status)) 457 else if (Hresult.Succeeded(e.Status))
434 { 458 {
435 if (this.Downgrade) 459 if (this.root.UpgradeDetectState == UpgradeDetectionState.Newer)
436 { 460 {
437 this.root.DetectState = DetectionState.Newer; 461 this.Downgrade = true;
438 var relatedPackages = WixBA.Model.BAManifest.Bundle.Packages.Values.Where(p => p.Type == PackageType.UpgradeBundle); 462 this.DowngradeMessage = "There is already a newer version of WiX installed on this machine.";
439 var installedVersion = relatedPackages.Any() ? new Version(relatedPackages.Max(p => p.Version)) : null;
440 if (installedVersion != null && installedVersion < new Version(4, 1) && installedVersion.Build > 10)
441 {
442 this.DowngradeMessage = "You must uninstall WiX v" + installedVersion + " before you can install this.";
443 }
444 else
445 {
446 this.DowngradeMessage = "There is already a newer version of WiX installed on this machine.";
447 }
448 } 463 }
449 464
450 if (LaunchAction.Layout == WixBA.Model.Command.Action) 465 if (LaunchAction.Layout == WixBA.Model.Command.Action)