Downgrade error to warning when search refs a reserved prefix variable.
The engine doesn't actually prevent external callers from setting variables that start with 'Wix'.
Sean Hall committed
Aug 1, 2022 at 17:07 UTC
28c8abfda013d6aa568fde8b26da65522748d376
15 files changed
+333
-35
src/api/wix/WixToolset.Extensibility/Data/BundleVariableNameRule.cs
new
+33
@@ -0,0 +1,33 @@
1
+// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
+
3
+namespace WixToolset.Extensibility.Data
4
+{
5
+ using System;
6
+
7
+ /// <summary>
8
+ /// When validating a bundle variable name, which special restrictions to ignore.
9
+ /// </summary>
10
+ [Flags]
11
+ public enum BundleVariableNameRule
12
+ {
13
+ /// <summary>
14
+ /// Enforce all special restrictions.
15
+ /// </summary>
16
+ EnforceAllRestrictions = 0x0,
17
+
18
+ /// <summary>
19
+ /// Allow names of built-in variables.
20
+ /// </summary>
21
+ CanBeBuiltIn = 0x1,
22
+
23
+ /// <summary>
24
+ /// Allow names of well-known variables.
25
+ /// </summary>
26
+ CanBeWellKnown = 0x2,
27
+
28
+ /// <summary>
29
+ /// Allow names that are not built-in and are not well-known and start with 'Wix'.
30
+ /// </summary>
31
+ CanHaveReservedPrefix = 0x4,
32
+ }
33
+}
src/api/wix/WixToolset.Extensibility/Services/IBundleValidator.cs
+23
-3
@@ -33,15 +33,35 @@ namespace WixToolset.Extensibility.Services
33
bool ValidateBundleMsiPropertyName(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string propertyName);
34
35
/// <summary>
36
- /// Validates a Bundle variable name and displays an error for an illegal value.
36
+ /// Validates a Bundle variable name that is being used to declare a Variable in the bundle manifest and displays an error for an illegal value.
37
/// </summary>
38
/// <param name="sourceLineNumbers"></param>
39
/// <param name="elementName"></param>
40
/// <param name="attributeName"></param>
41
/// <param name="variableName"></param>
42
- /// <param name="allowBuiltIn">Whether to bypass checks for reserved values.</param>
42
/// <returns>Whether the name is valid.</returns>
44
- bool ValidateBundleVariableName(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string variableName, bool allowBuiltIn);
43
+ bool ValidateBundleVariableNameDeclaration(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string variableName);
44
+
45
+ /// <summary>
46
+ /// Validates a Bundle variable name that is being used to reference a Variable and displays an error for an illegal value.
47
+ /// </summary>
48
+ /// <param name="sourceLineNumbers"></param>
49
+ /// <param name="elementName"></param>
50
+ /// <param name="attributeName"></param>
51
+ /// <param name="variableName"></param>
52
+ /// <param name="nameRule"></param>
53
+ /// <returns>Whether the name is valid.</returns>
54
+ bool ValidateBundleVariableNameValue(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string variableName, BundleVariableNameRule nameRule);
55
+
56
+ /// <summary>
57
+ /// Validates a Bundle variable name that is being used to set its value and displays an error for an illegal value.
58
+ /// </summary>
59
+ /// <param name="sourceLineNumbers"></param>
60
+ /// <param name="elementName"></param>
61
+ /// <param name="attributeName"></param>
62
+ /// <param name="variableName"></param>
63
+ /// <returns>Whether the name is valid.</returns>
64
+ bool ValidateBundleVariableNameTarget(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string variableName);
65
66
/// <summary>
67
/// Validates a bundle condition and displays an error for an illegal value.
src/api/wix/WixToolset.Extensibility/Services/IParseHelper.cs
+2
-1
@@ -246,8 +246,9 @@ namespace WixToolset.Extensibility.Services
246
/// </summary>
247
/// <param name="sourceLineNumbers">Source line information about the owner element.</param>
248
/// <param name="attribute">The attribute containing the value to get.</param>
249
+ /// <param name="nameRule">A rule for the contents of the value. If the contents do not follow the rule, an error is thrown.</param>
250
/// <returns>The attribute's value.</returns>
250
- string GetAttributeBundleVariableNameValue(SourceLineNumber sourceLineNumbers, XAttribute attribute);
251
+ string GetAttributeBundleVariableNameValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, BundleVariableNameRule nameRule = BundleVariableNameRule.CanBeWellKnown | BundleVariableNameRule.CanHaveReservedPrefix);
252
253
/// <summary>
254
/// Get a guid attribute value and displays an error for an illegal guid value.
src/burn/test/BurnUnitTest/VariableTest.cpp
+33
@@ -162,6 +162,39 @@ namespace Bootstrapper
162
}
163
}
164
165
+ [Fact]
166
+ void VariablesSetCustomWixVariableTest()
167
+ {
168
+ HRESULT hr = S_OK;
169
+ IXMLDOMElement* pixeBundle = NULL;
170
+ BURN_VARIABLES variables = { };
171
+
172
+ try
173
+ {
174
+ LPCWSTR wzDocument =
175
+ L"<Bundle>"
176
+ L" <CommandLine Variables='upperCase' />"
177
+ L"</Bundle>";
178
+
179
+ hr = VariableInitialize(&variables);
180
+ TestThrowOnFailure(hr, L"Failed to initialize variables.");
181
+
182
+ // load XML document
183
+ LoadBundleXmlHelper(wzDocument, &pixeBundle);
184
+
185
+ hr = VariablesParseFromXml(&variables, pixeBundle);
186
+ NativeAssert::Succeeded(hr, "Failed to parse variables from XML.");
187
+
188
+ hr = VariableSetString(&variables, L"WixCustomVariable", L"something", FALSE, FALSE);
189
+ NativeAssert::Succeeded(hr, "Failed to set 'WixCustomVariable' variable.");
190
+ }
191
+ finally
192
+ {
193
+ ReleaseObject(pixeBundle);
194
+ VariablesUninitialize(&variables);
195
+ }
196
+ }
197
+
198
[Fact]
199
void VariablesFormatTest()
200
{
src/ext/Util/test/WixToolsetTest.Util/TestData/BundleWithSearches/BundleUsingDiscouragedVariableNames.wxs
new
+19
@@ -0,0 +1,19 @@
1
+<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
2
+ <Bundle Name="!(loc.BundleName)" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a">
3
+ <BootstrapperApplication>
4
+ <BootstrapperApplicationDll SourceFile="fakeba.dll" />
5
+ </BootstrapperApplication>
6
+
7
+ <util:RegistrySearch
8
+ Variable="WixCustomVariable"
9
+ Root="HKLM"
10
+ Key="SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Custom"
11
+ Value="Release"
12
+ Result="value"
13
+ Bitness="always64" />
14
+
15
+ <Chain>
16
+ <MsiPackage SourceFile="test.msi" />
17
+ </Chain>
18
+ </Bundle>
19
+</Wix>
src/ext/Util/test/WixToolsetTest.Util/UtilExtensionFixture.cs
+54
-9
@@ -296,6 +296,53 @@ namespace WixToolsetTest.Util
296
}
297
}
298
299
+ [Fact]
300
+ public void CanBuildBundleWithWarningsWithSearchesUsingDiscouragedVariableNames()
301
+ {
302
+ var folder = TestData.Get("TestData", "BundleWithSearches");
303
+ var rootFolder = TestData.Get();
304
+ var wixext = Path.Combine(rootFolder, "WixToolset.Util.wixext.dll");
305
+
306
+ using (var fs = new DisposableFileSystem())
307
+ {
308
+ var baseFolder = fs.GetFolder();
309
+ var intermediateFolder = Path.Combine(baseFolder, "obj");
310
+ var bundlePath = Path.Combine(baseFolder, @"bin\test.exe");
311
+ var baFolderPath = Path.Combine(baseFolder, "ba");
312
+ var extractFolderPath = Path.Combine(baseFolder, "extract");
313
+
314
+ var result = WixRunner.Execute(false, new[]
315
+ {
316
+ "build",
317
+ Path.Combine(folder, "BundleUsingDiscouragedVariableNames.wxs"),
318
+ "-ext", wixext,
319
+ "-loc", Path.Combine(folder, "Bundle.en-us.wxl"),
320
+ "-bindpath", Path.Combine(folder, "data"),
321
+ "-intermediateFolder", intermediateFolder,
322
+ "-o", bundlePath,
323
+ });
324
+
325
+ var messages = result.Messages.Select(m => m.ToString()).ToList();
326
+ messages.Sort();
327
+
328
+ WixAssert.CompareLineByLine(new[]
329
+ {
330
+ "The *Search/@Variable attribute's value begins with the reserved prefix 'Wix'. Some prefixes are reserved by the WiX toolset for well-known values. Change your attribute's value to not begin with the same prefix.",
331
+ }, messages.ToArray());
332
+
333
+ result.AssertSuccess();
334
+
335
+ var extractResult = BundleExtractor.ExtractBAContainer(null, bundlePath, baFolderPath, extractFolderPath);
336
+ extractResult.AssertSuccess();
337
+
338
+ var utilSearches = extractResult.GetManifestTestXmlLines("/burn:BurnManifest/*[self::burn:ExtensionSearch or self::burn:DirectorySearch or self::burn:FileSearch or self::burn:MsiProductSearch or self::burn:RegistrySearch]");
339
+ WixAssert.CompareLineByLine(new[]
340
+ {
341
+ @"<RegistrySearch Id='wrsvJmsaXS39nKFUh9CVvRE6SSC4qk' Variable='WixCustomVariable' Root='HKLM' Key='SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Custom' Value='Release' Win64='yes' Type='value' VariableType='string' />",
342
+ }, utilSearches);
343
+ }
344
+ }
345
+
346
[Fact]
347
public void CannotBuildBundleWithSearchesUsingBuiltinVariableNames()
348
{
@@ -307,7 +354,6 @@ namespace WixToolsetTest.Util
354
{
355
var baseFolder = fs.GetFolder();
356
var intermediateFolder = Path.Combine(baseFolder, "obj");
310
- var bundlePath = Path.Combine(baseFolder, "bin", "test.exe");
357
358
var result = WixRunner.Execute(new[]
359
{
@@ -317,7 +363,7 @@ namespace WixToolsetTest.Util
363
"-loc", Path.Combine(folder, "Bundle.en-us.wxl"),
364
"-bindpath", Path.Combine(folder, "data"),
365
"-intermediateFolder", intermediateFolder,
320
- "-o", bundlePath
366
+ "-o", "bundle.wixlib",
367
});
368
369
var messages = result.Messages.Select(m => m.ToString()).ToList();
@@ -325,13 +371,12 @@ namespace WixToolsetTest.Util
371
372
WixAssert.CompareLineByLine(new[]
373
{
328
- "The DirectorySearch/@Variable attribute's value, 'InstallerName', is one of the illegal options: 'AdminToolsFolder', 'AppDataFolder', 'CommonAppDataFolder', 'CommonFiles64Folder', 'CommonFilesFolder', 'CompatibilityMode', 'Date', 'DesktopFolder', 'FavoritesFolder', 'FontsFolder', 'InstallerName', 'InstallerVersion', 'LocalAppDataFolder', 'LogonUser', 'MyPicturesFolder', 'NativeMachine', 'NTProductType', 'NTSuiteBackOffice', 'NTSuiteDataCenter', 'NTSuiteEnterprise', 'NTSuitePersonal', 'NTSuiteSmallBusiness', 'NTSuiteSmallBusinessRestricted', 'NTSuiteWebServer', 'PersonalFolder', 'Privileged', 'ProgramFiles64Folder', 'ProgramFiles6432Folder', 'ProgramFilesFolder', 'ProgramMenuFolder', 'RebootPending', 'SendToFolder', 'ServicePackLevel', 'StartMenuFolder', 'StartupFolder', 'System64Folder', 'SystemFolder', 'TempFolder', 'TemplateFolder', 'TerminalServer', 'UserLanguageID', 'UserUILanguageID', 'VersionMsi', 'VersionNT', 'VersionNT64', 'WindowsFolder', 'WindowsVolume', 'WixBundleAction', 'WixBundleCommandLineAction', 'WixBundleForcedRestartPackage', 'WixBundleElevated', 'WixBundleInstalled', 'WixBundleProviderKey', 'WixBundleTag', or 'WixBundleVersion'.",
329
- "The FileSearch/@Variable attribute's value, 'NativeMachine', is one of the illegal options: 'AdminToolsFolder', 'AppDataFolder', 'CommonAppDataFolder', 'CommonFiles64Folder', 'CommonFilesFolder', 'CompatibilityMode', 'Date', 'DesktopFolder', 'FavoritesFolder', 'FontsFolder', 'InstallerName', 'InstallerVersion', 'LocalAppDataFolder', 'LogonUser', 'MyPicturesFolder', 'NativeMachine', 'NTProductType', 'NTSuiteBackOffice', 'NTSuiteDataCenter', 'NTSuiteEnterprise', 'NTSuitePersonal', 'NTSuiteSmallBusiness', 'NTSuiteSmallBusinessRestricted', 'NTSuiteWebServer', 'PersonalFolder', 'Privileged', 'ProgramFiles64Folder', 'ProgramFiles6432Folder', 'ProgramFilesFolder', 'ProgramMenuFolder', 'RebootPending', 'SendToFolder', 'ServicePackLevel', 'StartMenuFolder', 'StartupFolder', 'System64Folder', 'SystemFolder', 'TempFolder', 'TemplateFolder', 'TerminalServer', 'UserLanguageID', 'UserUILanguageID', 'VersionMsi', 'VersionNT', 'VersionNT64', 'WindowsFolder', 'WindowsVolume', 'WixBundleAction', 'WixBundleCommandLineAction', 'WixBundleForcedRestartPackage', 'WixBundleElevated', 'WixBundleInstalled', 'WixBundleProviderKey', 'WixBundleTag', or 'WixBundleVersion'.",
330
- "The ProductSearch/@Variable attribute's value, 'Date', is one of the illegal options: 'AdminToolsFolder', 'AppDataFolder', 'CommonAppDataFolder', 'CommonFiles64Folder', 'CommonFilesFolder', 'CompatibilityMode', 'Date', 'DesktopFolder', 'FavoritesFolder', 'FontsFolder', 'InstallerName', 'InstallerVersion', 'LocalAppDataFolder', 'LogonUser', 'MyPicturesFolder', 'NativeMachine', 'NTProductType', 'NTSuiteBackOffice', 'NTSuiteDataCenter', 'NTSuiteEnterprise', 'NTSuitePersonal', 'NTSuiteSmallBusiness', 'NTSuiteSmallBusinessRestricted', 'NTSuiteWebServer', 'PersonalFolder', 'Privileged', 'ProgramFiles64Folder', 'ProgramFiles6432Folder', 'ProgramFilesFolder', 'ProgramMenuFolder', 'RebootPending', 'SendToFolder', 'ServicePackLevel', 'StartMenuFolder', 'StartupFolder', 'System64Folder', 'SystemFolder', 'TempFolder', 'TemplateFolder', 'TerminalServer', 'UserLanguageID', 'UserUILanguageID', 'VersionMsi', 'VersionNT', 'VersionNT64', 'WindowsFolder', 'WindowsVolume', 'WixBundleAction', 'WixBundleCommandLineAction', 'WixBundleForcedRestartPackage', 'WixBundleElevated', 'WixBundleInstalled', 'WixBundleProviderKey', 'WixBundleTag', or 'WixBundleVersion'.",
331
- "The RegistrySearch/@Variable attribute's value begins with the reserved prefix 'Wix'. Some prefixes are reserved by the WiX toolset for well-known values. Change your attribute's value to not begin with the same prefix.",
332
- "The RegistrySearch/@Variable attribute's value, 'VersionNT64', is one of the illegal options: 'AdminToolsFolder', 'AppDataFolder', 'CommonAppDataFolder', 'CommonFiles64Folder', 'CommonFilesFolder', 'CompatibilityMode', 'Date', 'DesktopFolder', 'FavoritesFolder', 'FontsFolder', 'InstallerName', 'InstallerVersion', 'LocalAppDataFolder', 'LogonUser', 'MyPicturesFolder', 'NativeMachine', 'NTProductType', 'NTSuiteBackOffice', 'NTSuiteDataCenter', 'NTSuiteEnterprise', 'NTSuitePersonal', 'NTSuiteSmallBusiness', 'NTSuiteSmallBusinessRestricted', 'NTSuiteWebServer', 'PersonalFolder', 'Privileged', 'ProgramFiles64Folder', 'ProgramFiles6432Folder', 'ProgramFilesFolder', 'ProgramMenuFolder', 'RebootPending', 'SendToFolder', 'ServicePackLevel', 'StartMenuFolder', 'StartupFolder', 'System64Folder', 'SystemFolder', 'TempFolder', 'TemplateFolder', 'TerminalServer', 'UserLanguageID', 'UserUILanguageID', 'VersionMsi', 'VersionNT', 'VersionNT64', 'WindowsFolder', 'WindowsVolume', 'WixBundleAction', 'WixBundleCommandLineAction', 'WixBundleForcedRestartPackage', 'WixBundleElevated', 'WixBundleInstalled', 'WixBundleProviderKey', 'WixBundleTag', or 'WixBundleVersion'.",
333
- "The RegistrySearch/@Variable attribute's value, 'WixBundleAction', is one of the illegal options: 'AdminToolsFolder', 'AppDataFolder', 'CommonAppDataFolder', 'CommonFiles64Folder', 'CommonFilesFolder', 'CompatibilityMode', 'Date', 'DesktopFolder', 'FavoritesFolder', 'FontsFolder', 'InstallerName', 'InstallerVersion', 'LocalAppDataFolder', 'LogonUser', 'MyPicturesFolder', 'NativeMachine', 'NTProductType', 'NTSuiteBackOffice', 'NTSuiteDataCenter', 'NTSuiteEnterprise', 'NTSuitePersonal', 'NTSuiteSmallBusiness', 'NTSuiteSmallBusinessRestricted', 'NTSuiteWebServer', 'PersonalFolder', 'Privileged', 'ProgramFiles64Folder', 'ProgramFiles6432Folder', 'ProgramFilesFolder', 'ProgramMenuFolder', 'RebootPending', 'SendToFolder', 'ServicePackLevel', 'StartMenuFolder', 'StartupFolder', 'System64Folder', 'SystemFolder', 'TempFolder', 'TemplateFolder', 'TerminalServer', 'UserLanguageID', 'UserUILanguageID', 'VersionMsi', 'VersionNT', 'VersionNT64', 'WindowsFolder', 'WindowsVolume', 'WixBundleAction', 'WixBundleCommandLineAction', 'WixBundleForcedRestartPackage', 'WixBundleElevated', 'WixBundleInstalled', 'WixBundleProviderKey', 'WixBundleTag', or 'WixBundleVersion'.",
334
- "The WindowsFeatureSearch/@Variable attribute's value, 'NTProductType', is one of the illegal options: 'AdminToolsFolder', 'AppDataFolder', 'CommonAppDataFolder', 'CommonFiles64Folder', 'CommonFilesFolder', 'CompatibilityMode', 'Date', 'DesktopFolder', 'FavoritesFolder', 'FontsFolder', 'InstallerName', 'InstallerVersion', 'LocalAppDataFolder', 'LogonUser', 'MyPicturesFolder', 'NativeMachine', 'NTProductType', 'NTSuiteBackOffice', 'NTSuiteDataCenter', 'NTSuiteEnterprise', 'NTSuitePersonal', 'NTSuiteSmallBusiness', 'NTSuiteSmallBusinessRestricted', 'NTSuiteWebServer', 'PersonalFolder', 'Privileged', 'ProgramFiles64Folder', 'ProgramFiles6432Folder', 'ProgramFilesFolder', 'ProgramMenuFolder', 'RebootPending', 'SendToFolder', 'ServicePackLevel', 'StartMenuFolder', 'StartupFolder', 'System64Folder', 'SystemFolder', 'TempFolder', 'TemplateFolder', 'TerminalServer', 'UserLanguageID', 'UserUILanguageID', 'VersionMsi', 'VersionNT', 'VersionNT64', 'WindowsFolder', 'WindowsVolume', 'WixBundleAction', 'WixBundleCommandLineAction', 'WixBundleForcedRestartPackage', 'WixBundleElevated', 'WixBundleInstalled', 'WixBundleProviderKey', 'WixBundleTag', or 'WixBundleVersion'.",
374
+ "The DirectorySearch/@Variable attribute's value, 'InstallerName', is one of the illegal options: 'AdminToolsFolder', 'AppDataFolder', 'CommonAppDataFolder', 'CommonFiles64Folder', 'CommonFiles6432Folder', 'CommonFilesFolder', 'CompatibilityMode', 'ComputerName', 'Date', 'DesktopFolder', 'FavoritesFolder', 'FontsFolder', 'InstallerName', 'InstallerVersion', 'LocalAppDataFolder', 'LogonUser', 'MyPicturesFolder', 'NativeMachine', 'NTProductType', 'NTSuiteBackOffice', 'NTSuiteDataCenter', 'NTSuiteEnterprise', 'NTSuitePersonal', 'NTSuiteSmallBusiness', 'NTSuiteSmallBusinessRestricted', 'NTSuiteWebServer', 'PersonalFolder', 'Privileged', 'ProcessorArchitecture', 'ProgramFiles64Folder', 'ProgramFiles6432Folder', 'ProgramFilesFolder', 'ProgramMenuFolder', 'RebootPending', 'SendToFolder', 'ServicePackLevel', 'StartMenuFolder', 'StartupFolder', 'System64Folder', 'SystemFolder', 'SystemLanguageID', 'TempFolder', 'TemplateFolder', 'TerminalServer', 'UserLanguageID', 'UserUILanguageID', 'VersionMsi', 'VersionNT', 'VersionNT64', 'WindowsBuildNumber', 'WindowsFolder', 'WindowsVolume', 'WixBundleAction', 'WixBundleActiveParent', 'WixBundleCommandLineAction', 'WixBundleElevated', 'WixBundleExecutePackageAction', 'WixBundleExecutePackageCacheFolder', 'WixBundleForcedRestartPackage', 'WixBundleInstalled', 'WixBundleProviderKey', 'WixBundleSourceProcessFolder', 'WixBundleSourceProcessPath', 'WixBundleTag', 'WixBundleUILevel', or 'WixBundleVersion'.",
375
+ "The FileSearch/@Variable attribute's value, 'NativeMachine', is one of the illegal options: 'AdminToolsFolder', 'AppDataFolder', 'CommonAppDataFolder', 'CommonFiles64Folder', 'CommonFiles6432Folder', 'CommonFilesFolder', 'CompatibilityMode', 'ComputerName', 'Date', 'DesktopFolder', 'FavoritesFolder', 'FontsFolder', 'InstallerName', 'InstallerVersion', 'LocalAppDataFolder', 'LogonUser', 'MyPicturesFolder', 'NativeMachine', 'NTProductType', 'NTSuiteBackOffice', 'NTSuiteDataCenter', 'NTSuiteEnterprise', 'NTSuitePersonal', 'NTSuiteSmallBusiness', 'NTSuiteSmallBusinessRestricted', 'NTSuiteWebServer', 'PersonalFolder', 'Privileged', 'ProcessorArchitecture', 'ProgramFiles64Folder', 'ProgramFiles6432Folder', 'ProgramFilesFolder', 'ProgramMenuFolder', 'RebootPending', 'SendToFolder', 'ServicePackLevel', 'StartMenuFolder', 'StartupFolder', 'System64Folder', 'SystemFolder', 'SystemLanguageID', 'TempFolder', 'TemplateFolder', 'TerminalServer', 'UserLanguageID', 'UserUILanguageID', 'VersionMsi', 'VersionNT', 'VersionNT64', 'WindowsBuildNumber', 'WindowsFolder', 'WindowsVolume', 'WixBundleAction', 'WixBundleActiveParent', 'WixBundleCommandLineAction', 'WixBundleElevated', 'WixBundleExecutePackageAction', 'WixBundleExecutePackageCacheFolder', 'WixBundleForcedRestartPackage', 'WixBundleInstalled', 'WixBundleProviderKey', 'WixBundleSourceProcessFolder', 'WixBundleSourceProcessPath', 'WixBundleTag', 'WixBundleUILevel', or 'WixBundleVersion'.",
376
+ "The ProductSearch/@Variable attribute's value, 'Date', is one of the illegal options: 'AdminToolsFolder', 'AppDataFolder', 'CommonAppDataFolder', 'CommonFiles64Folder', 'CommonFiles6432Folder', 'CommonFilesFolder', 'CompatibilityMode', 'ComputerName', 'Date', 'DesktopFolder', 'FavoritesFolder', 'FontsFolder', 'InstallerName', 'InstallerVersion', 'LocalAppDataFolder', 'LogonUser', 'MyPicturesFolder', 'NativeMachine', 'NTProductType', 'NTSuiteBackOffice', 'NTSuiteDataCenter', 'NTSuiteEnterprise', 'NTSuitePersonal', 'NTSuiteSmallBusiness', 'NTSuiteSmallBusinessRestricted', 'NTSuiteWebServer', 'PersonalFolder', 'Privileged', 'ProcessorArchitecture', 'ProgramFiles64Folder', 'ProgramFiles6432Folder', 'ProgramFilesFolder', 'ProgramMenuFolder', 'RebootPending', 'SendToFolder', 'ServicePackLevel', 'StartMenuFolder', 'StartupFolder', 'System64Folder', 'SystemFolder', 'SystemLanguageID', 'TempFolder', 'TemplateFolder', 'TerminalServer', 'UserLanguageID', 'UserUILanguageID', 'VersionMsi', 'VersionNT', 'VersionNT64', 'WindowsBuildNumber', 'WindowsFolder', 'WindowsVolume', 'WixBundleAction', 'WixBundleActiveParent', 'WixBundleCommandLineAction', 'WixBundleElevated', 'WixBundleExecutePackageAction', 'WixBundleExecutePackageCacheFolder', 'WixBundleForcedRestartPackage', 'WixBundleInstalled', 'WixBundleProviderKey', 'WixBundleSourceProcessFolder', 'WixBundleSourceProcessPath', 'WixBundleTag', 'WixBundleUILevel', or 'WixBundleVersion'.",
377
+ "The RegistrySearch/@Variable attribute's value, 'VersionNT64', is one of the illegal options: 'AdminToolsFolder', 'AppDataFolder', 'CommonAppDataFolder', 'CommonFiles64Folder', 'CommonFiles6432Folder', 'CommonFilesFolder', 'CompatibilityMode', 'ComputerName', 'Date', 'DesktopFolder', 'FavoritesFolder', 'FontsFolder', 'InstallerName', 'InstallerVersion', 'LocalAppDataFolder', 'LogonUser', 'MyPicturesFolder', 'NativeMachine', 'NTProductType', 'NTSuiteBackOffice', 'NTSuiteDataCenter', 'NTSuiteEnterprise', 'NTSuitePersonal', 'NTSuiteSmallBusiness', 'NTSuiteSmallBusinessRestricted', 'NTSuiteWebServer', 'PersonalFolder', 'Privileged', 'ProcessorArchitecture', 'ProgramFiles64Folder', 'ProgramFiles6432Folder', 'ProgramFilesFolder', 'ProgramMenuFolder', 'RebootPending', 'SendToFolder', 'ServicePackLevel', 'StartMenuFolder', 'StartupFolder', 'System64Folder', 'SystemFolder', 'SystemLanguageID', 'TempFolder', 'TemplateFolder', 'TerminalServer', 'UserLanguageID', 'UserUILanguageID', 'VersionMsi', 'VersionNT', 'VersionNT64', 'WindowsBuildNumber', 'WindowsFolder', 'WindowsVolume', 'WixBundleAction', 'WixBundleActiveParent', 'WixBundleCommandLineAction', 'WixBundleElevated', 'WixBundleExecutePackageAction', 'WixBundleExecutePackageCacheFolder', 'WixBundleForcedRestartPackage', 'WixBundleInstalled', 'WixBundleProviderKey', 'WixBundleSourceProcessFolder', 'WixBundleSourceProcessPath', 'WixBundleTag', 'WixBundleUILevel', or 'WixBundleVersion'.",
378
+ "The RegistrySearch/@Variable attribute's value, 'WixBundleAction', is one of the illegal options: 'AdminToolsFolder', 'AppDataFolder', 'CommonAppDataFolder', 'CommonFiles64Folder', 'CommonFiles6432Folder', 'CommonFilesFolder', 'CompatibilityMode', 'ComputerName', 'Date', 'DesktopFolder', 'FavoritesFolder', 'FontsFolder', 'InstallerName', 'InstallerVersion', 'LocalAppDataFolder', 'LogonUser', 'MyPicturesFolder', 'NativeMachine', 'NTProductType', 'NTSuiteBackOffice', 'NTSuiteDataCenter', 'NTSuiteEnterprise', 'NTSuitePersonal', 'NTSuiteSmallBusiness', 'NTSuiteSmallBusinessRestricted', 'NTSuiteWebServer', 'PersonalFolder', 'Privileged', 'ProcessorArchitecture', 'ProgramFiles64Folder', 'ProgramFiles6432Folder', 'ProgramFilesFolder', 'ProgramMenuFolder', 'RebootPending', 'SendToFolder', 'ServicePackLevel', 'StartMenuFolder', 'StartupFolder', 'System64Folder', 'SystemFolder', 'SystemLanguageID', 'TempFolder', 'TemplateFolder', 'TerminalServer', 'UserLanguageID', 'UserUILanguageID', 'VersionMsi', 'VersionNT', 'VersionNT64', 'WindowsBuildNumber', 'WindowsFolder', 'WindowsVolume', 'WixBundleAction', 'WixBundleActiveParent', 'WixBundleCommandLineAction', 'WixBundleElevated', 'WixBundleExecutePackageAction', 'WixBundleExecutePackageCacheFolder', 'WixBundleForcedRestartPackage', 'WixBundleInstalled', 'WixBundleProviderKey', 'WixBundleSourceProcessFolder', 'WixBundleSourceProcessPath', 'WixBundleTag', 'WixBundleUILevel', or 'WixBundleVersion'.",
379
+ "The WindowsFeatureSearch/@Variable attribute's value, 'NTProductType', is one of the illegal options: 'AdminToolsFolder', 'AppDataFolder', 'CommonAppDataFolder', 'CommonFiles64Folder', 'CommonFiles6432Folder', 'CommonFilesFolder', 'CompatibilityMode', 'ComputerName', 'Date', 'DesktopFolder', 'FavoritesFolder', 'FontsFolder', 'InstallerName', 'InstallerVersion', 'LocalAppDataFolder', 'LogonUser', 'MyPicturesFolder', 'NativeMachine', 'NTProductType', 'NTSuiteBackOffice', 'NTSuiteDataCenter', 'NTSuiteEnterprise', 'NTSuitePersonal', 'NTSuiteSmallBusiness', 'NTSuiteSmallBusinessRestricted', 'NTSuiteWebServer', 'PersonalFolder', 'Privileged', 'ProcessorArchitecture', 'ProgramFiles64Folder', 'ProgramFiles6432Folder', 'ProgramFilesFolder', 'ProgramMenuFolder', 'RebootPending', 'SendToFolder', 'ServicePackLevel', 'StartMenuFolder', 'StartupFolder', 'System64Folder', 'SystemFolder', 'SystemLanguageID', 'TempFolder', 'TemplateFolder', 'TerminalServer', 'UserLanguageID', 'UserUILanguageID', 'VersionMsi', 'VersionNT', 'VersionNT64', 'WindowsBuildNumber', 'WindowsFolder', 'WindowsVolume', 'WixBundleAction', 'WixBundleActiveParent', 'WixBundleCommandLineAction', 'WixBundleElevated', 'WixBundleExecutePackageAction', 'WixBundleExecutePackageCacheFolder', 'WixBundleForcedRestartPackage', 'WixBundleInstalled', 'WixBundleProviderKey', 'WixBundleSourceProcessFolder', 'WixBundleSourceProcessPath', 'WixBundleTag', 'WixBundleUILevel', or 'WixBundleVersion'.",
380
}, messages.ToArray());
381
}
382
}
src/wix/WixToolset.Core.Burn/Bundles/PerformBundleBackendValidationCommand.cs
+2
-2
@@ -163,7 +163,7 @@ namespace WixToolset.Core.Burn.Bundles
163
164
private void ValidateSearch(WixSearchSymbol symbol)
165
{
166
- this.BackendHelper.ValidateBundleVariableName(symbol.SourceLineNumbers, "*Search", "Variable", symbol.Variable, allowBuiltIn: false);
166
+ this.BackendHelper.ValidateBundleVariableNameTarget(symbol.SourceLineNumbers, "*Search", "Variable", symbol.Variable);
167
168
if (symbol.Condition != null)
169
{
@@ -173,7 +173,7 @@ namespace WixToolset.Core.Burn.Bundles
173
174
private void ValidateVariable(WixBundleVariableSymbol symbol)
175
{
176
- this.BackendHelper.ValidateBundleVariableName(symbol.SourceLineNumbers, "Variable", "Name", symbol.Id.Id, allowBuiltIn: false);
176
+ this.BackendHelper.ValidateBundleVariableNameDeclaration(symbol.SourceLineNumbers, "Variable", "Name", symbol.Id.Id);
177
}
178
}
179
}
src/wix/WixToolset.Core.Burn/ExtensibilityServices/BurnBackendHelper.cs
+12
-2
@@ -190,9 +190,19 @@ namespace WixToolset.Core.Burn.ExtensibilityServices
190
return this.bundleValidator.ValidateBundleMsiPropertyName(sourceLineNumbers, elementName, attributeName, propertyName);
191
}
192
193
- public bool ValidateBundleVariableName(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string variableName, bool allowBuiltIn)
193
+ public bool ValidateBundleVariableNameDeclaration(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string variableName)
194
{
195
- return this.bundleValidator.ValidateBundleVariableName(sourceLineNumbers, elementName, attributeName, variableName, allowBuiltIn);
195
+ return this.bundleValidator.ValidateBundleVariableNameDeclaration(sourceLineNumbers, elementName, attributeName, variableName);
196
+ }
197
+
198
+ public bool ValidateBundleVariableNameValue(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string variableName, BundleVariableNameRule nameRule)
199
+ {
200
+ return this.bundleValidator.ValidateBundleVariableNameValue(sourceLineNumbers, elementName, attributeName, variableName, nameRule);
201
+ }
202
+
203
+ public bool ValidateBundleVariableNameTarget(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string variableName)
204
+ {
205
+ return this.bundleValidator.ValidateBundleVariableNameTarget(sourceLineNumbers, elementName, attributeName, variableName);
206
}
207
208
public bool ValidateBundleCondition(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string condition, BundleConditionPhase phase)
src/wix/WixToolset.Core/CompilerWarnings.cs
+12
@@ -36,11 +36,21 @@ namespace WixToolset.Core
36
return Message(sourceLineNumbers, Ids.ProvidesKeyNotFound, "The provider key with identifier {0} was not found in the Wix4DependencyProvider table. Related registry rows will not be removed from authoring.", id);
37
}
38
39
+ public static Message ReadonlyLogVariableTarget(SourceLineNumber sourceLineNumbers, string element, string attribute, string name)
40
+ {
41
+ return Message(sourceLineNumbers, Ids.ReadonlyLogVariableTarget, "The {0}/@{1} attribute's value references the well-known log Variable '{2}' to change its value. This variable is set by the engine and is intended to be read-only. Change your attribute's value to reference a custom variable.", element, attribute, name);
42
+ }
43
+
44
public static Message RequiresKeyNotFound(SourceLineNumber sourceLineNumbers, string id)
45
{
46
return Message(sourceLineNumbers, Ids.RequiresKeyNotFound, "The dependency key with identifier {0} was not found in the Wix4Dependency table. Related registry rows will not be removed from authoring.", id);
47
}
48
49
+ public static Message ReservedBurnNamespaceWarning(SourceLineNumber sourceLineNumbers, string element, string attribute, string prefix)
50
+ {
51
+ return Message(sourceLineNumbers, Ids.ReservedBurnNamespaceWarning, "The {0}/@{1} attribute's value begins with the reserved prefix '{2}'. Some prefixes are reserved by the WiX toolset for well-known values. Change your attribute's value to not begin with the same prefix.", element, attribute, prefix);
52
+ }
53
+
54
public static Message Win64Component(SourceLineNumber sourceLineNumbers, string componentId)
55
{
56
return Message(sourceLineNumbers, Ids.Win64Component, "The Provides element should not be authored in the 64-bit component with identifier {0}. The dependency feature may not work if installing this package on 64-bit Windows operating systems prior to Windows 7 and Windows Server 2008 R2. Set the Component/@Bitness attribute to \"always32\" to ensure the dependency feature works correctly on legacy operating systems.", componentId);
@@ -60,6 +70,8 @@ namespace WixToolset.Core
70
Win64Component = 5435,
71
DirectoryRefStandardDirectoryDeprecated = 5436,
72
DefiningStandardDirectoryDeprecated = 5437,
73
+ ReadonlyLogVariableTarget = 5438,
74
+ ReservedBurnNamespaceWarning = 5439,
75
} // 5400-5499 and 6600-6699 were the ranges for Dependency and Tag which are now in Core between CompilerWarnings and CompilerErrors.
76
}
77
}
src/wix/WixToolset.Core/ExtensibilityServices/BundleValidator.cs
+117
-3
@@ -109,6 +109,21 @@ namespace WixToolset.Core.ExtensibilityServices
109
"WixBundleVersion",
110
});
111
112
+ // Well-known variables (from burn\engine\variable.cpp, "vrgWellKnownVariables", around line 304)
113
+ private static readonly List<string> WellKnownBundleVariables = new List<string>(
114
+ new string[] {
115
+ "WixBundleInProgressName",
116
+ "WixBundleLastUsedSource",
117
+ "WixBundleLayoutDirectory",
118
+ "WixBundleLog",
119
+ "WixBundleLog_*",
120
+ "WixBundleRollbackLog_*",
121
+ "WixBundleManufacturer",
122
+ "WixBundleName",
123
+ "WixBundleOriginalSource",
124
+ "WixBundleOriginalSourceFolder",
125
+ });
126
+
127
private static readonly List<string> DisallowedMsiProperties = new List<string>(
128
new string[] {
129
"ACTION",
@@ -156,7 +171,7 @@ namespace WixToolset.Core.ExtensibilityServices
171
return relativePath;
172
}
173
159
- public bool ValidateBundleVariableName(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string variableName, bool allowBuiltIn)
174
+ public bool ValidateBundleVariableNameDeclaration(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string variableName)
175
{
176
if (String.IsNullOrEmpty(variableName))
177
{
@@ -170,14 +185,14 @@ namespace WixToolset.Core.ExtensibilityServices
185
186
return false;
187
}
173
- else if (!allowBuiltIn && BuiltinBundleVariables.Contains(variableName))
188
+ else if (BuiltinBundleVariables.Contains(variableName))
189
{
190
var illegalValues = CreateValueList(ValueListKind.Or, BuiltinBundleVariables);
191
this.Messaging.Write(ErrorMessages.IllegalAttributeValueWithIllegalList(sourceLineNumbers, elementName, attributeName, variableName, illegalValues));
192
193
return false;
194
}
180
- else if (!allowBuiltIn && variableName.StartsWith("Wix", StringComparison.OrdinalIgnoreCase))
195
+ else if (variableName.StartsWith("Wix", StringComparison.OrdinalIgnoreCase))
196
{
197
this.Messaging.Write(ErrorMessages.ReservedBurnNamespaceViolation(sourceLineNumbers, elementName, attributeName, "Wix"));
198
@@ -189,6 +204,105 @@ namespace WixToolset.Core.ExtensibilityServices
204
}
205
}
206
207
+ public bool ValidateBundleVariableNameValue(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string variableName, BundleVariableNameRule nameRule)
208
+ {
209
+ if (String.IsNullOrEmpty(variableName))
210
+ {
211
+ this.Messaging.Write(ErrorMessages.IllegalEmptyAttributeValue(sourceLineNumbers, elementName, attributeName));
212
+
213
+ return false;
214
+ }
215
+ else if (!Common.IsBundleVariableName(variableName))
216
+ {
217
+ this.Messaging.Write(CompilerErrors.IllegalBundleVariableName(sourceLineNumbers, elementName, attributeName, variableName));
218
+
219
+ return false;
220
+ }
221
+ else if (BuiltinBundleVariables.Contains(variableName))
222
+ {
223
+ var allowed = nameRule.HasFlag(BundleVariableNameRule.CanBeBuiltIn);
224
+ if (!allowed)
225
+ {
226
+ var illegalValues = CreateValueList(ValueListKind.Or, BuiltinBundleVariables);
227
+ this.Messaging.Write(ErrorMessages.IllegalAttributeValueWithIllegalList(sourceLineNumbers, elementName, attributeName, variableName, illegalValues));
228
+ }
229
+
230
+ return allowed;
231
+ }
232
+ else if (WellKnownBundleVariables.Contains(variableName) ||
233
+ variableName.StartsWith("WixBundleLog_", StringComparison.OrdinalIgnoreCase) ||
234
+ variableName.StartsWith("WixBundleRollbackLog_", StringComparison.OrdinalIgnoreCase))
235
+ {
236
+ var allowed = nameRule.HasFlag(BundleVariableNameRule.CanBeWellKnown);
237
+ if (!allowed)
238
+ {
239
+ var illegalValues = CreateValueList(ValueListKind.Or, WellKnownBundleVariables);
240
+ this.Messaging.Write(ErrorMessages.IllegalAttributeValueWithIllegalList(sourceLineNumbers, elementName, attributeName, variableName, illegalValues));
241
+ }
242
+
243
+ return allowed;
244
+ }
245
+ else if (variableName.StartsWith("Wix", StringComparison.OrdinalIgnoreCase))
246
+ {
247
+ var allowed = nameRule.HasFlag(BundleVariableNameRule.CanHaveReservedPrefix);
248
+ if (!allowed)
249
+ {
250
+ this.Messaging.Write(ErrorMessages.ReservedBurnNamespaceViolation(sourceLineNumbers, elementName, attributeName, "Wix"));
251
+ }
252
+
253
+ return allowed;
254
+ }
255
+ else
256
+ {
257
+ return true;
258
+ }
259
+ }
260
+
261
+ public bool ValidateBundleVariableNameTarget(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string variableName)
262
+ {
263
+ if (String.IsNullOrEmpty(variableName))
264
+ {
265
+ this.Messaging.Write(ErrorMessages.IllegalEmptyAttributeValue(sourceLineNumbers, elementName, attributeName));
266
+
267
+ return false;
268
+ }
269
+ else if (!Common.IsBundleVariableName(variableName))
270
+ {
271
+ this.Messaging.Write(CompilerErrors.IllegalBundleVariableName(sourceLineNumbers, elementName, attributeName, variableName));
272
+
273
+ return false;
274
+ }
275
+ else if (BuiltinBundleVariables.Contains(variableName))
276
+ {
277
+ var illegalValues = CreateValueList(ValueListKind.Or, BuiltinBundleVariables);
278
+ this.Messaging.Write(ErrorMessages.IllegalAttributeValueWithIllegalList(sourceLineNumbers, elementName, attributeName, variableName, illegalValues));
279
+
280
+ return false;
281
+ }
282
+ else if (variableName.Equals("WixBundleLog", StringComparison.OrdinalIgnoreCase) ||
283
+ variableName.StartsWith("WixBundleLog_", StringComparison.OrdinalIgnoreCase) ||
284
+ variableName.StartsWith("WixBundleRollbackLog_", StringComparison.OrdinalIgnoreCase))
285
+ {
286
+ this.Messaging.Write(CompilerWarnings.ReadonlyLogVariableTarget(sourceLineNumbers, elementName, attributeName, variableName));
287
+
288
+ return true;
289
+ }
290
+ else if (WellKnownBundleVariables.Contains(variableName))
291
+ {
292
+ return true;
293
+ }
294
+ else if (variableName.StartsWith("Wix", StringComparison.OrdinalIgnoreCase))
295
+ {
296
+ this.Messaging.Write(CompilerWarnings.ReservedBurnNamespaceWarning(sourceLineNumbers, elementName, attributeName, "Wix"));
297
+
298
+ return true;
299
+ }
300
+ else
301
+ {
302
+ return true;
303
+ }
304
+ }
305
+
306
public bool ValidateBundleMsiPropertyName(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string propertyName)
307
{
308
if (String.IsNullOrEmpty(propertyName))
src/wix/WixToolset.Core/ExtensibilityServices/ParseHelper.cs
+6
-6
@@ -246,9 +246,9 @@ namespace WixToolset.Core.ExtensibilityServices
246
{
247
this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, elementName, "Variable"));
248
}
249
- else
249
+ else if (!this.IsValidLocIdentifier(variable) && !Common.IsValidBinderVariable(variable))
250
{
251
- this.BundleValidator.ValidateBundleVariableName(sourceLineNumbers, elementName, "Variable", variable, allowBuiltIn: false);
251
+ this.BundleValidator.ValidateBundleVariableNameValue(sourceLineNumbers, elementName, "Variable", variable, BundleVariableNameRule.CanBeWellKnown | BundleVariableNameRule.CanHaveReservedPrefix);
252
}
253
254
section.AddSymbol(new WixSearchSymbol(sourceLineNumbers, id)
@@ -322,19 +322,19 @@ namespace WixToolset.Core.ExtensibilityServices
322
323
if (!String.IsNullOrEmpty(variableId?.Id))
324
{
325
- this.BundleValidator.ValidateBundleVariableName(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, variableId.Id, allowBuiltIn: false);
325
+ this.BundleValidator.ValidateBundleVariableNameDeclaration(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, variableId.Id);
326
}
327
328
return variableId;
329
}
330
331
- public string GetAttributeBundleVariableNameValue(SourceLineNumber sourceLineNumbers, XAttribute attribute)
331
+ public string GetAttributeBundleVariableNameValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, BundleVariableNameRule nameRule = BundleVariableNameRule.CanBeWellKnown | BundleVariableNameRule.CanHaveReservedPrefix)
332
{
333
var variableName = this.GetAttributeValue(sourceLineNumbers, attribute);
334
335
- if (!String.IsNullOrEmpty(variableName))
335
+ if (!String.IsNullOrEmpty(variableName) && !this.IsValidLocIdentifier(variableName) && !Common.IsValidBinderVariable(variableName))
336
{
337
- this.BundleValidator.ValidateBundleVariableName(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, variableName, allowBuiltIn: false);
337
+ this.BundleValidator.ValidateBundleVariableNameValue(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, variableName, nameRule);
338
}
339
340
return variableName;
src/wix/test/WixToolsetTest.CoreIntegration/BadInputFixture.cs
+16
-8
@@ -7,6 +7,7 @@ namespace WixToolsetTest.CoreIntegration
7
using System.Linq;
8
using WixBuildTools.TestSupport;
9
using WixToolset.Core.TestPackage;
10
+ using WixToolset.Data;
11
using Xunit;
12
13
public class BadInputFixture
@@ -179,12 +180,11 @@ namespace WixToolsetTest.CoreIntegration
180
181
WixAssert.CompareLineByLine(new[]
182
{
182
- "The SetVariable/@Variable attribute's value, '!(loc.BuiltinBurnVariableName)', is not a legal bundle variable name. Identifiers may contain ASCII characters A-Z, a-z, digits, or underscores (_). Every identifier must begin with either a letter or an underscore.",
183
"The Variable/@Name attribute was not found; it is required.",
184
"The Variable/@Name attribute's value, '!(loc.BuiltinBurnVariableName)', is not a legal identifier. Identifiers may contain ASCII characters A-Z, a-z, digits, underscores (_), or periods (.). Every identifier must begin with either a letter or an underscore.",
185
}, messages.ToArray());
186
187
- Assert.Equal(6603, result.ExitCode);
187
+ Assert.Equal(10, result.ExitCode);
188
}
189
}
190
@@ -212,7 +212,6 @@ namespace WixToolsetTest.CoreIntegration
212
213
WixAssert.CompareLineByLine(new[]
214
{
215
- "The SetVariable/@Variable attribute's value begins with the reserved prefix 'Wix'. Some prefixes are reserved by the WiX toolset for well-known values. Change your attribute's value to not begin with the same prefix.",
215
"The SetVariable/@Variable attribute's value, 'WixBundleInstalled', is one of the illegal options: 'AdminToolsFolder', 'AppDataFolder', 'CommonAppDataFolder', 'CommonFiles64Folder', 'CommonFiles6432Folder', 'CommonFilesFolder', 'CompatibilityMode', 'ComputerName', 'Date', 'DesktopFolder', 'FavoritesFolder', 'FontsFolder', 'InstallerName', 'InstallerVersion', 'LocalAppDataFolder', 'LogonUser', 'MyPicturesFolder', 'NativeMachine', 'NTProductType', 'NTSuiteBackOffice', 'NTSuiteDataCenter', 'NTSuiteEnterprise', 'NTSuitePersonal', 'NTSuiteSmallBusiness', 'NTSuiteSmallBusinessRestricted', 'NTSuiteWebServer', 'PersonalFolder', 'Privileged', 'ProcessorArchitecture', 'ProgramFiles64Folder', 'ProgramFiles6432Folder', 'ProgramFilesFolder', 'ProgramMenuFolder', 'RebootPending', 'SendToFolder', 'ServicePackLevel', 'StartMenuFolder', 'StartupFolder', 'System64Folder', 'SystemFolder', 'SystemLanguageID', 'TempFolder', 'TemplateFolder', 'TerminalServer', 'UserLanguageID', 'UserUILanguageID', 'VersionMsi', 'VersionNT', 'VersionNT64', 'WindowsBuildNumber', 'WindowsFolder', 'WindowsVolume', 'WixBundleAction', 'WixBundleActiveParent', 'WixBundleCommandLineAction', 'WixBundleElevated', 'WixBundleExecutePackageAction', 'WixBundleExecutePackageCacheFolder', 'WixBundleForcedRestartPackage', 'WixBundleInstalled', 'WixBundleProviderKey', 'WixBundleSourceProcessFolder', 'WixBundleSourceProcessPath', 'WixBundleTag', 'WixBundleUILevel', or 'WixBundleVersion'.",
216
"The Variable/@Name attribute's value begins with the reserved prefix 'Wix'. Some prefixes are reserved by the WiX toolset for well-known values. Change your attribute's value to not begin with the same prefix.",
217
"The Variable/@Name attribute's value, 'AppDataFolder', is one of the illegal options: 'AdminToolsFolder', 'AppDataFolder', 'CommonAppDataFolder', 'CommonFiles64Folder', 'CommonFiles6432Folder', 'CommonFilesFolder', 'CompatibilityMode', 'ComputerName', 'Date', 'DesktopFolder', 'FavoritesFolder', 'FontsFolder', 'InstallerName', 'InstallerVersion', 'LocalAppDataFolder', 'LogonUser', 'MyPicturesFolder', 'NativeMachine', 'NTProductType', 'NTSuiteBackOffice', 'NTSuiteDataCenter', 'NTSuiteEnterprise', 'NTSuitePersonal', 'NTSuiteSmallBusiness', 'NTSuiteSmallBusinessRestricted', 'NTSuiteWebServer', 'PersonalFolder', 'Privileged', 'ProcessorArchitecture', 'ProgramFiles64Folder', 'ProgramFiles6432Folder', 'ProgramFilesFolder', 'ProgramMenuFolder', 'RebootPending', 'SendToFolder', 'ServicePackLevel', 'StartMenuFolder', 'StartupFolder', 'System64Folder', 'SystemFolder', 'SystemLanguageID', 'TempFolder', 'TemplateFolder', 'TerminalServer', 'UserLanguageID', 'UserUILanguageID', 'VersionMsi', 'VersionNT', 'VersionNT64', 'WindowsBuildNumber', 'WindowsFolder', 'WindowsVolume', 'WixBundleAction', 'WixBundleActiveParent', 'WixBundleCommandLineAction', 'WixBundleElevated', 'WixBundleExecutePackageAction', 'WixBundleExecutePackageCacheFolder', 'WixBundleForcedRestartPackage', 'WixBundleInstalled', 'WixBundleProviderKey', 'WixBundleSourceProcessFolder', 'WixBundleSourceProcessPath', 'WixBundleTag', 'WixBundleUILevel', or 'WixBundleVersion'.",
@@ -232,7 +231,7 @@ namespace WixToolsetTest.CoreIntegration
231
var baseFolder = fs.GetFolder();
232
var intermediateFolder = Path.Combine(baseFolder, "obj");
233
235
- var result = WixRunner.Execute(new[]
234
+ var result = WixRunner.Execute(false, new[]
235
{
236
"build",
237
Path.Combine(folder, "BundleWithInvalid", "BundleWithInvalidLocValues.wxs"),
@@ -244,21 +243,30 @@ namespace WixToolsetTest.CoreIntegration
243
"-o", Path.Combine(baseFolder, @"bin\test.exe")
244
});
245
247
- var messages = result.Messages.Select(m => m.ToString()).ToList();
248
- messages.Sort();
246
+ var warningMessages = result.Messages.Where(m => m.Level == MessageLevel.Warning).Select(m => m.ToString()).ToList();
247
+ warningMessages.Sort();
248
249
WixAssert.CompareLineByLine(new[]
250
{
251
"*Search/@Condition contains the built-in Variable 'WixBundleAction', which is not available when it is evaluated. (Unavailable Variables are: 'WixBundleAction'.). Rewrite the condition to avoid Variables that are never valid during its evaluation.",
252
"Bundle/@Condition contains the built-in Variable 'WixBundleInstalled', which is not available when it is evaluated. (Unavailable Variables are: 'RebootPending', 'WixBundleAction', or 'WixBundleInstalled'.). Rewrite the condition to avoid Variables that are never valid during its evaluation.",
253
"ExePackage/@DetectCondition contains the built-in Variable 'WixBundleAction', which is not available when it is evaluated. (Unavailable Variables are: 'WixBundleAction'.). Rewrite the condition to avoid Variables that are never valid during its evaluation.",
254
+ "The *Search/@Variable attribute's value begins with the reserved prefix 'Wix'. Some prefixes are reserved by the WiX toolset for well-known values. Change your attribute's value to not begin with the same prefix.",
255
+ "The *Search/@Variable attribute's value references the well-known log Variable 'WixBundleLog' to change its value. This variable is set by the engine and is intended to be read-only. Change your attribute's value to reference a custom variable.",
256
+ }, warningMessages.ToArray());
257
+
258
+ var errorMessages = result.Messages.Where(m => m.Level == MessageLevel.Error).Select(m => m.ToString()).ToList();
259
+ errorMessages.Sort();
260
+
261
+ WixAssert.CompareLineByLine(new[]
262
+ {
263
"The CommandLine/@Condition attribute's value '=' is not a valid bundle condition.",
264
"The MsiPackage/@InstallCondition attribute's value '=' is not a valid bundle condition.",
265
"The MsiProperty/@Condition attribute's value '=' is not a valid bundle condition.",
266
"The 'REINSTALLMODE' MsiProperty is controlled by the bootstrapper and cannot be authored. (Illegal properties are: 'ACTION', 'ADDLOCAL', 'ADDSOURCE', 'ADDDEFAULT', 'ADVERTISE', 'ALLUSERS', 'REBOOT', 'REINSTALL', 'REINSTALLMODE', or 'REMOVE'.) Remove the MsiProperty element.",
259
- }, messages.ToArray());
267
+ }, errorMessages.ToArray());
268
261
- Assert.Equal(1159, result.ExitCode);
269
+ Assert.Equal(409, result.ExitCode);
270
}
271
}
272
}
src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleWithInvalid/BundleWithInvalidLocValues.wxl
+2
@@ -1,6 +1,8 @@
1
<WixLocalization xmlns="http://wixtoolset.org/schemas/v4/wxl" Culture="en-US">
2
<String Id="BuiltinMsiPropertyName">REINSTALLMODE</String>
3
<String Id="BuiltinBurnVariableName">WixBundleInstalled</String>
4
+ <String Id="BurnLogVariableName">WixBundleLog</String>
5
+ <String Id="BurnReservedPrefixVariableName">WixCustomVariable</String>
6
<String Id="NonsenseDetectCondition">WixBundleAction = 4</String>
7
<String Id="NonsenseExecuteCondition">=</String>
8
<String Id="NonsenseGlobalCondition">WixBundleInstalled <> 1</String>
src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleWithInvalid/BundleWithInvalidLocValues.wxs
+2
@@ -13,5 +13,7 @@
13
</ExePackage>
14
</Chain>
15
<SetVariable Id="Builtin" Condition="!(loc.NonsenseDetectCondition)" Variable="FOO" Value="1" />
16
+ <SetVariable Id="LogWellKnown" Variable="!(loc.BurnLogVariableName)" Value="2" />
17
+ <SetVariable Id="ReservedPrefix" Variable="!(loc.BurnReservedPrefixVariableName)" Value="3" />
18
</Bundle>
19
</Wix>
src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleWithInvalid/BundleWithReservedVariableNames.wxs
-1
@@ -1,7 +1,6 @@
1
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
2
<Fragment>
3
<SetVariable Id="Builtin" Variable="WixBundleInstalled" Value="1" />
4
- <SetVariable Id="Builtin" Variable="WixDoesNotExist" Value="2" />
4
<Variable Name="WixCustomVariable" />
5
<Variable Name="AppDataFolder" />
6
</Fragment>