From c1605aa577e304fe0fb4c57056b58754bfaf3666 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Fri, 8 Jan 2021 13:46:36 -0800 Subject: Require or recommend ExePackage/@DetectCondition Fixes wixtoolset/issues#6197 --- src/WixToolset.Core/Compiler_Bundle.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/WixToolset.Core') diff --git a/src/WixToolset.Core/Compiler_Bundle.cs b/src/WixToolset.Core/Compiler_Bundle.cs index 40b44bbd..1bee3823 100644 --- a/src/WixToolset.Core/Compiler_Bundle.cs +++ b/src/WixToolset.Core/Compiler_Bundle.cs @@ -2232,7 +2232,7 @@ namespace WixToolset.Core allowed = (packageType == WixBundlePackageType.Exe || packageType == WixBundlePackageType.Msp); break; case "DetectCondition": - detectCondition = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + detectCondition = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); allowed = (packageType == WixBundlePackageType.Exe || packageType == WixBundlePackageType.Msu); break; case "Protocol": @@ -2394,6 +2394,20 @@ namespace WixToolset.Core perMachine = YesNoDefaultType.Default; } + // Detect condition is recommended or required for Exe and Msu packages + // (depending on whether uninstall arguments were provided). + if ((packageType == WixBundlePackageType.Exe || packageType == WixBundlePackageType.Msu) && String.IsNullOrEmpty(detectCondition)) + { + if (String.IsNullOrEmpty(uninstallCommand)) + { + this.Core.Write(WarningMessages.DetectConditionRecommended(sourceLineNumbers, node.Name.LocalName)); + } + else + { + this.Core.Write(ErrorMessages.ExpectedAttributeWithValueWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, "DetectCondition", "UninstallCommand")); + } + } + // Now that the package ID is known, we can parse the extension attributes... var contextValues = new Dictionary() { { "PackageId", id.Id } }; foreach (var attribute in extensionAttributes) -- cgit v1.2.3-55-g6feb