Add converter error message when TARGETDIR ref is removed
Fixes 7187
Rob Mensching committed
Feb 9, 2023 at 07:42 UTC
4d0b22438b5795e7a92c227f1c824b8da853d859
3 files changed
+17
-3
src/wix/WixToolset.Converters/WixConverter.cs
+7
@@ -1123,6 +1123,8 @@ namespace WixToolset.Converters
1123
if (this.OnInformation(ConverterTestType.StandardDirectoryRefDeprecated, element, "The {0} directory should no longer be explicitly referenced. Remove the DirectoryRef element with Id attribute '{0}'.", id))
1124
{
1125
RemoveElementKeepChildren(element);
1126
+
1127
+ this.OnError(ConverterTestType.TargetDirRefRemoved, element, "A reference to the TARGETDIR Directory was removed. This may cause the Fragment that defined TARGETDIR to not be included in the final output. If this happens, reference a different element in the Fragment to replace the old reference to TARGEDIR.");
1128
}
1129
}
1130
else if (this.OnInformation(ConverterTestType.StandardDirectoryRefDeprecated, element, "The standard directory '{0}' should no longer be directly referenced. Use the StandardDirectory element instead.", id))
@@ -3300,6 +3302,11 @@ namespace WixToolset.Converters
3302
/// The magic WixVariable 'WixMbaPrereqPackageId' has been removed. Add bal:PrereqPackage="yes" to the target package instead.
3303
/// </summary>
3304
WixMbaPrereqPackageIdDeprecated,
3305
+
3306
+ /// <summary>
3307
+ /// A reference to the TARGETDIR Directory was removed. This may cause the Fragment that defined TARGETDIR to not be included in the final output. If this happens, reference a different element in the Fragment to replace the old reference to TARGEDIR.
3308
+ /// </summary>
3309
+ TargetDirRefRemoved,
3310
}
3311
}
3312
}
src/wix/test/WixToolsetTest.Converters/ConverterFixture.cs
+1
-1
@@ -298,7 +298,7 @@ namespace WixToolsetTest.Converters
298
299
WixAssert.CompareLineByLine(expected, actual);
300
Assert.Equal(Wix4Namespace, document.Root.GetDefaultNamespace());
301
- Assert.Equal(3, errors);
301
+ Assert.Equal(4, errors);
302
}
303
304
[Fact]
src/wix/test/WixToolsetTest.Converters/DirectoryFixture.cs
+9
-2
@@ -89,7 +89,14 @@ namespace WixToolsetTest.Converters
89
90
var actualLines = UnformattedDocumentLines(document);
91
WixAssert.CompareLineByLine(expected, actualLines);
92
- Assert.Equal(3, errors);
92
+ WixAssert.CompareLineByLine(new[]
93
+ {
94
+ "[Converted] This file contains an XML declaration on the first line. (DeclarationPresent)",
95
+ "[Converted] The namespace 'http://schemas.microsoft.com/wix/2006/wi' is out of date. It must be 'http://wixtoolset.org/schemas/v4/wxs'. (XmlnsValueWrong)",
96
+ "[Converted] The TARGETDIR directory should no longer be explicitly referenced. Remove the DirectoryRef element with Id attribute 'TARGETDIR'. (StandardDirectoryRefDeprecated)",
97
+ "A reference to the TARGETDIR Directory was removed. This may cause the Fragment that defined TARGETDIR to not be included in the final output. If this happens, reference a different element in the Fragment to replace the old reference to TARGEDIR. (TargetDirRefRemoved)",
98
+ }, messaging.Messages.Select(m => m.ToString()).ToArray());
99
+ Assert.Equal(4, errors);
100
}
101
102
[Fact]
@@ -201,7 +208,7 @@ namespace WixToolsetTest.Converters
208
209
var actualLines = UnformattedDocumentLines(document);
210
WixAssert.CompareLineByLine(expected, actualLines);
204
- Assert.Equal(4, errors);
211
+ Assert.Equal(5, errors);
212
}
213
214
[Fact]