From 3441afb46c4dc056493ab84f9b27434c4185d713 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sat, 10 Apr 2021 15:04:04 -0700 Subject: Improve implicit Component/@Id generation and duplicate GUID errors --- src/WixToolset.Core/Compiler.cs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'src/WixToolset.Core/Compiler.cs') diff --git a/src/WixToolset.Core/Compiler.cs b/src/WixToolset.Core/Compiler.cs index c5f3a763..c39bec70 100644 --- a/src/WixToolset.Core/Compiler.cs +++ b/src/WixToolset.Core/Compiler.cs @@ -2454,24 +2454,27 @@ namespace WixToolset.Core } } - // check for conditions that exclude this component from using generated guids - var isGeneratableGuidOk = "*" == guid; - if (isGeneratableGuidOk) + // Check for conditions that exclude this component from using implicit ids and/or generated guids. + var allowImplicitIds = true; + if (encounteredODBCDataSource || ComponentKeyPathType.Directory == keyPathType) { - if (encounteredODBCDataSource || ComponentKeyPathType.Directory == keyPathType) + allowImplicitIds = false; + if (guid == "*") { this.Core.Write(ErrorMessages.IllegalComponentWithAutoGeneratedGuid(sourceLineNumbers)); - isGeneratableGuidOk = false; } - else if (0 < files && ComponentKeyPathType.Registry == keyPathType) + } + else if (0 < files && ComponentKeyPathType.Registry == keyPathType) + { + allowImplicitIds = false; + if (guid == "*") { this.Core.Write(ErrorMessages.IllegalComponentWithAutoGeneratedGuid(sourceLineNumbers, true)); - isGeneratableGuidOk = false; } } - // check for implicit KeyPath which can easily be accidentally changed - if (this.ShowPedanticMessages && !keyFound && !isGeneratableGuidOk) + // Check for implicit KeyPath which can easily be accidentally changed + if (this.ShowPedanticMessages && !keyFound && !allowImplicitIds) { this.Core.Write(ErrorMessages.ImplicitComponentKeyPath(sourceLineNumbers, id.Id)); } @@ -2481,7 +2484,7 @@ namespace WixToolset.Core // generatable guid must be met. if (componentIdPlaceholder == id.Id) { - if (isGeneratableGuidOk || keyFound && !String.IsNullOrEmpty(keyPath)) + if (allowImplicitIds || keyFound && !String.IsNullOrEmpty(keyPath)) { this.componentIdPlaceholders.Add(componentIdPlaceholder, keyPath); -- cgit v1.2.3-55-g6feb