diff options
| author | Rob Mensching <rob@firegiant.com> | 2020-06-12 12:46:48 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2020-06-13 09:22:27 -0700 |
| commit | 86b7ea7a411813e03a2b238ca5c24fcebc947209 (patch) | |
| tree | 722bdc9463a6773df4242725ec340975e6c28641 /src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs | |
| parent | 404e5661ee971b9b2544185c3a28b24fafc06185 (diff) | |
| download | wix-86b7ea7a411813e03a2b238ca5c24fcebc947209.tar.gz wix-86b7ea7a411813e03a2b238ca5c24fcebc947209.tar.bz2 wix-86b7ea7a411813e03a2b238ca5c24fcebc947209.zip | |
Move validate guids to a command and execute it earlier
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs')
| -rw-r--r-- | src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs | 49 |
1 files changed, 5 insertions, 44 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs index 65e4bf13..e0dd2b96 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs | |||
| @@ -319,6 +319,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 319 | command.Execute(); | 319 | command.Execute(); |
| 320 | } | 320 | } |
| 321 | 321 | ||
| 322 | { | ||
| 323 | var command = new ValidateComponentGuidsCommand(this.Messaging, section); | ||
| 324 | command.Execute(); | ||
| 325 | } | ||
| 326 | |||
| 322 | // Add missing CreateFolder tuples to null-keypath components. | 327 | // Add missing CreateFolder tuples to null-keypath components. |
| 323 | { | 328 | { |
| 324 | var command = new AddCreateFoldersCommand(section); | 329 | var command = new AddCreateFoldersCommand(section); |
| @@ -407,8 +412,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 407 | } | 412 | } |
| 408 | #endif | 413 | #endif |
| 409 | 414 | ||
| 410 | this.ValidateComponentGuids(output); | ||
| 411 | |||
| 412 | // Stop processing if an error previously occurred. | 415 | // Stop processing if an error previously occurred. |
| 413 | if (this.Messaging.EncounteredError) | 416 | if (this.Messaging.EncounteredError) |
| 414 | { | 417 | { |
| @@ -579,48 +582,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 579 | return wixout; | 582 | return wixout; |
| 580 | } | 583 | } |
| 581 | 584 | ||
| 582 | /// <summary> | ||
| 583 | /// Validate that there are no duplicate GUIDs in the output. | ||
| 584 | /// </summary> | ||
| 585 | /// <remarks> | ||
| 586 | /// Duplicate GUIDs without conditions are an error condition; with conditions, it's a | ||
| 587 | /// warning, as the conditions might be mutually exclusive. | ||
| 588 | /// </remarks> | ||
| 589 | private void ValidateComponentGuids(WindowsInstallerData output) | ||
| 590 | { | ||
| 591 | if (output.TryGetTable("Component", out var componentTable)) | ||
| 592 | { | ||
| 593 | var componentGuidConditions = new Dictionary<string, bool>(componentTable.Rows.Count); | ||
| 594 | |||
| 595 | foreach (Data.WindowsInstaller.Rows.ComponentRow row in componentTable.Rows) | ||
| 596 | { | ||
| 597 | // We don't care about unmanaged components and if there's a * GUID remaining, | ||
| 598 | // there's already an error that prevented it from being replaced with a real GUID. | ||
| 599 | if (!String.IsNullOrEmpty(row.Guid) && "*" != row.Guid) | ||
| 600 | { | ||
| 601 | var thisComponentHasCondition = !String.IsNullOrEmpty(row.Condition); | ||
| 602 | var allComponentsHaveConditions = thisComponentHasCondition; | ||
| 603 | |||
| 604 | if (componentGuidConditions.ContainsKey(row.Guid)) | ||
| 605 | { | ||
| 606 | allComponentsHaveConditions = thisComponentHasCondition && componentGuidConditions[row.Guid]; | ||
| 607 | |||
| 608 | if (allComponentsHaveConditions) | ||
| 609 | { | ||
| 610 | this.Messaging.Write(WarningMessages.DuplicateComponentGuidsMustHaveMutuallyExclusiveConditions(row.SourceLineNumbers, row.Component, row.Guid)); | ||
| 611 | } | ||
| 612 | else | ||
| 613 | { | ||
| 614 | this.Messaging.Write(ErrorMessages.DuplicateComponentGuids(row.SourceLineNumbers, row.Component, row.Guid)); | ||
| 615 | } | ||
| 616 | } | ||
| 617 | |||
| 618 | componentGuidConditions[row.Guid] = allComponentsHaveConditions; | ||
| 619 | } | ||
| 620 | } | ||
| 621 | } | ||
| 622 | } | ||
| 623 | |||
| 624 | private string ResolveMedia(MediaTuple media, string mediaLayoutDirectory, string layoutDirectory) | 585 | private string ResolveMedia(MediaTuple media, string mediaLayoutDirectory, string layoutDirectory) |
| 625 | { | 586 | { |
| 626 | string layout = null; | 587 | string layout = null; |
