@joebigelow / wix / commits / 7a386978

Display error correctly with multiple properties in a Property value

Fixes 7173

Rob Mensching committed Jan 20, 2023 at 09:52 UTC 7a3869780e294be7d4ae38d1215c6e5e84798d2f
3 files changed +41 -1
src/wix/WixToolset.Core/Compiler.cs
+1 -1
@@ -365,7 +365,7 @@ namespace WixToolset.Core
365 break;
366 }
367
368 - var id = value.Substring(start + 1, end - 1);
368 + var id = value.Substring(start + 1, end - start - 1);
369 if (Common.IsIdentifier(id))
370 {
371 this.Core.Write(WarningMessages.PropertyValueContainsPropertyReference(sourceLineNumbers, propertyId.Id, id));
src/wix/test/WixToolsetTest.CoreIntegration/MsiFixture.cs
+27
@@ -494,6 +494,33 @@ namespace WixToolsetTest.CoreIntegration
494 }
495 }
496
497 + [Fact]
498 + public void CannotBuildBadProperty()
499 + {
500 + var folder = TestData.Get(@"TestData", "Property");
501 +
502 + using (var fs = new DisposableFileSystem())
503 + {
504 + var baseFolder = fs.GetFolder();
505 + var intermediateFolder = Path.Combine(baseFolder, "obj");
506 +
507 + var result = WixRunner.Execute(new[]
508 + {
509 + "build",
510 + Path.Combine(folder, "BadProperty.wxs"),
511 + "-intermediateFolder", intermediateFolder,
512 + "-o", Path.Combine(baseFolder, "bin", "test.msi")
513 + });
514 +
515 + var messages = result.Messages.Select(m => m.ToString()).ToArray();
516 + WixAssert.CompareLineByLine(new[]
517 + {
518 + "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.",
519 + "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.",
520 + }, messages);
521 + }
522 + }
523 +
524 [Fact]
525 public void CanBuildSetProperty()
526 {
src/wix/test/WixToolsetTest.CoreIntegration/TestData/Property/BadProperty.wxs new
+13
@@ -0,0 +1,13 @@
1 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
2 + <Package Name="Bad Property" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a">
3 + <MajorUpgrade DowngradeErrorMessage="Downgrade error message." />
4 +
5 + <Property Id="Break" Value="[X] [Y]" />
6 +
7 + <Feature Id="ProductFeature">
8 + <Component Directory="ProgramFilesFolder" Subdirectory="MsiPackage">
9 + <File Source="BadProperty.wxs" />
10 + </Component>
11 + </Feature>
12 + </Package>
13 +</Wix>