Skip to content

Commit

Permalink
Remove warning for Wix bundle variable prefix.
Browse files Browse the repository at this point in the history
It's a bit overzealous.

Fixes wixtoolset/issues#7579.
  • Loading branch information
barnson committed Jan 2, 2024
1 parent 59ca477 commit 44a13ff
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 97 deletions.
2 changes: 1 addition & 1 deletion src/api/wix/WixToolset.Data/ErrorMessages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1773,7 +1773,7 @@ public static Message ReservedBurnNamespaceViolation(SourceLineNumber sourceLine

public static Message ReservedNamespaceViolation(SourceLineNumber sourceLineNumbers, string element, string attribute, string prefix)
{
return Message(sourceLineNumbers, Ids.ReservedNamespaceViolation, "The {0}/@{1} attribute's value begins with the reserved prefix '{2}'. Some prefixes are reserved by the Windows Installer and WiX toolset for well-known values. Change your attribute's value to not begin with the same prefix.", element, attribute, prefix);
return Message(sourceLineNumbers, Ids.ReservedNamespaceViolation, "The {0}/@{1} attribute's value begins with the reserved prefix '{2}'. Some prefixes are reserved by the Windows Installer and WiX Toolset for well-known values. Change your attribute's value to not begin with the same prefix.", element, attribute, prefix);
}

public static Message RootFeatureCannotFollowParent(SourceLineNumber sourceLineNumbers)
Expand Down
35 changes: 35 additions & 0 deletions src/ext/NetFx/test/WixToolsetTest.Netfx/NetfxExtensionFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,41 @@ public void CanBuildUsingNetFx481Packages()
}
}

[Fact]
public void CanBuildUsingNetFxSearches()
{
using (var fs = new DisposableFileSystem())
{
var baseFolder = fs.GetFolder();
var bundleFile = Path.Combine(baseFolder, "bin", "test.exe");
var bundleSourceFolder = TestData.Get(@"TestData\UsingNetFxSearches");
var intermediateFolder = Path.Combine(baseFolder, "obj");

var extensionResult = WixRunner.Execute(warningsAsErrors: true, new[]
{
"extension", "add",
"WixToolset.Bal.wixext",
"extension", "add",
"WixToolset.Util.wixext",
});

var compileResult = WixRunner.Execute(new[]
{
"build",
Path.Combine(bundleSourceFolder, "BundleLatest.wxs"),
"-ext", "WixToolset.Bal.wixext",
"-ext", "WixToolset.Util.wixext",
"-ext", TestData.Get(@"WixToolset.Netfx.wixext.dll"),
"-intermediateFolder", intermediateFolder,
"-o", bundleFile,
"-arch", "x64",
});
compileResult.AssertSuccess();

Assert.True(File.Exists(bundleFile));
}
}

[Fact]
public void CanBuildUsingNativeImage()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
<Bundle Name="NetFxPackageGroup481" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="{1A204524-03F4-4641-BDF3-2A272A34A888}">
<BootstrapperApplication>
<bal:WixStandardBootstrapperApplication LicenseUrl="http://wixtoolset.org/about/license/" Theme="hyperlinkLicense" />
</BootstrapperApplication>

<util:RegistrySearchRef Id="WixNetFramework4xInstalledRelease" />

<Chain>
<PackageGroupRef Id="NetFx481RedistAsPrereq" />
</Chain>
</Bundle>
</Wix>

This file was deleted.

47 changes: 0 additions & 47 deletions src/ext/Util/test/WixToolsetTest.Util/UtilExtensionFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -470,53 +470,6 @@ public void CanCreateUserAccountWithComment()
}, results.OrderBy(s => s).ToArray());
}

[Fact]
public void CanBuildBundleWithWarningsWithSearchesUsingDiscouragedVariableNames()
{
var folder = TestData.Get("TestData", "BundleWithSearches");
var rootFolder = TestData.Get();
var wixext = Path.Combine(rootFolder, "WixToolset.Util.wixext.dll");

using (var fs = new DisposableFileSystem())
{
var baseFolder = fs.GetFolder();
var intermediateFolder = Path.Combine(baseFolder, "obj");
var bundlePath = Path.Combine(baseFolder, @"bin\test.exe");
var baFolderPath = Path.Combine(baseFolder, "ba");
var extractFolderPath = Path.Combine(baseFolder, "extract");

var result = WixRunner.Execute(false, new[]
{
"build",
Path.Combine(folder, "BundleUsingDiscouragedVariableNames.wxs"),
"-ext", wixext,
"-loc", Path.Combine(folder, "Bundle.en-us.wxl"),
"-bindpath", Path.Combine(folder, "data"),
"-intermediateFolder", intermediateFolder,
"-o", bundlePath,
});

var messages = result.Messages.Select(m => m.ToString()).ToList();
messages.Sort();

WixAssert.CompareLineByLine(new[]
{
"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.",
}, messages.ToArray());

result.AssertSuccess();

var extractResult = BundleExtractor.ExtractBAContainer(null, bundlePath, baFolderPath, extractFolderPath);
extractResult.AssertSuccess();

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]");
WixAssert.CompareLineByLine(new[]
{
@"<RegistrySearch Id='wrsvJmsaXS39nKFUh9CVvRE6SSC4qk' Variable='WixCustomVariable' Root='HKLM' Key='SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Custom' Value='Release' Win64='yes' Type='value' VariableType='string' />",
}, utilSearches);
}
}

[Fact]
public void CannotBuildBundleWithSearchesUsingBuiltinVariableNames()
{
Expand Down
7 changes: 1 addition & 6 deletions src/wix/WixToolset.Core/CompilerWarnings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ public static Message RequiresKeyNotFound(SourceLineNumber sourceLineNumbers, st
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);
}

public static Message ReservedBurnNamespaceWarning(SourceLineNumber sourceLineNumbers, string element, string attribute, string prefix)
{
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);
}

public static Message Win64Component(SourceLineNumber sourceLineNumbers, string componentId)
{
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);
Expand All @@ -71,7 +66,7 @@ public enum Ids
DirectoryRefStandardDirectoryDeprecated = 5436,
DefiningStandardDirectoryDeprecated = 5437,
ReadonlyLogVariableTarget = 5438,
ReservedBurnNamespaceWarning = 5439,
// DO_NOT_REUSE ReservedBurnNamespaceWarning = 5439,
} // 5400-5499 and 6600-6699 were the ranges for Dependency and Tag which are now in Core between CompilerWarnings and CompilerErrors.
}
}
22 changes: 0 additions & 22 deletions src/wix/WixToolset.Core/ExtensibilityServices/BundleValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,6 @@ public bool ValidateBundleVariableNameDeclaration(SourceLineNumber sourceLineNum

return false;
}
else if (variableName.StartsWith("Wix", StringComparison.OrdinalIgnoreCase))
{
this.Messaging.Write(ErrorMessages.ReservedBurnNamespaceViolation(sourceLineNumbers, elementName, attributeName, "Wix"));

return false;
}
else
{
return true;
Expand Down Expand Up @@ -242,16 +236,6 @@ public bool ValidateBundleVariableNameValue(SourceLineNumber sourceLineNumbers,

return allowed;
}
else if (variableName.StartsWith("Wix", StringComparison.OrdinalIgnoreCase))
{
var allowed = nameRule.HasFlag(BundleVariableNameRule.CanHaveReservedPrefix);
if (!allowed)
{
this.Messaging.Write(ErrorMessages.ReservedBurnNamespaceViolation(sourceLineNumbers, elementName, attributeName, "Wix"));
}

return allowed;
}
else
{
return true;
Expand Down Expand Up @@ -291,12 +275,6 @@ public bool ValidateBundleVariableNameTarget(SourceLineNumber sourceLineNumbers,
{
return true;
}
else if (variableName.StartsWith("Wix", StringComparison.OrdinalIgnoreCase))
{
this.Messaging.Write(CompilerWarnings.ReservedBurnNamespaceWarning(sourceLineNumbers, elementName, attributeName, "Wix"));

return true;
}
else
{
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ public void CannotBuildBundleWithReservedVariableNames()
WixAssert.CompareLineByLine(new[]
{
"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'.",
"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.",
"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'.",
}, messages.ToArray());

Expand Down Expand Up @@ -283,7 +282,6 @@ public void GuardsAgainstVariousBundleValuesFromLoc()
"*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.",
"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.",
"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.",
"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.",
"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.",
}, warningMessages);

Expand Down

0 comments on commit 44a13ff

Please sign in to comment.