From 7a3869780e294be7d4ae38d1215c6e5e84798d2f Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Fri, 20 Jan 2023 09:52:33 -0800 Subject: Display error correctly with multiple properties in a Property value Fixes 7173 --- src/wix/WixToolset.Core/Compiler.cs | 2 +- .../WixToolsetTest.CoreIntegration/MsiFixture.cs | 27 ++++++++++++++++++++++ .../TestData/Property/BadProperty.wxs | 13 +++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 src/wix/test/WixToolsetTest.CoreIntegration/TestData/Property/BadProperty.wxs diff --git a/src/wix/WixToolset.Core/Compiler.cs b/src/wix/WixToolset.Core/Compiler.cs index 3da24e2f..fa53b4d0 100644 --- a/src/wix/WixToolset.Core/Compiler.cs +++ b/src/wix/WixToolset.Core/Compiler.cs @@ -365,7 +365,7 @@ namespace WixToolset.Core break; } - var id = value.Substring(start + 1, end - 1); + var id = value.Substring(start + 1, end - start - 1); if (Common.IsIdentifier(id)) { this.Core.Write(WarningMessages.PropertyValueContainsPropertyReference(sourceLineNumbers, propertyId.Id, id)); diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/MsiFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/MsiFixture.cs index 808f9d92..a7dbe542 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/MsiFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/MsiFixture.cs @@ -494,6 +494,33 @@ namespace WixToolsetTest.CoreIntegration } } + [Fact] + public void CannotBuildBadProperty() + { + var folder = TestData.Get(@"TestData", "Property"); + + using (var fs = new DisposableFileSystem()) + { + var baseFolder = fs.GetFolder(); + var intermediateFolder = Path.Combine(baseFolder, "obj"); + + var result = WixRunner.Execute(new[] + { + "build", + Path.Combine(folder, "BadProperty.wxs"), + "-intermediateFolder", intermediateFolder, + "-o", Path.Combine(baseFolder, "bin", "test.msi") + }); + + var messages = result.Messages.Select(m => m.ToString()).ToArray(); + WixAssert.CompareLineByLine(new[] + { + "The 'Break' Property contains '[X]' in its value which is an illegal reference to another property. If this value is a string literal, not a property reference, please ignore this warning. To set a property with the value of another property, use a CustomAction with Property and Value attributes.", + "The 'Break' Property contains '[Y]' in its value which is an illegal reference to another property. If this value is a string literal, not a property reference, please ignore this warning. To set a property with the value of another property, use a CustomAction with Property and Value attributes.", + }, messages); + } + } + [Fact] public void CanBuildSetProperty() { diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Property/BadProperty.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Property/BadProperty.wxs new file mode 100644 index 00000000..2ab6f7d8 --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Property/BadProperty.wxs @@ -0,0 +1,13 @@ + + + + + + + + + + + + + -- cgit v1.2.3-55-g6feb