diff options
| author | Rob Mensching <rob@firegiant.com> | 2021-04-06 09:34:57 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2021-04-06 16:10:05 -0700 |
| commit | 86e59fdbc94ae661ca682f04cddb60d7830ae8a8 (patch) | |
| tree | 227b19100f4f116abdd4b4996688a86d58ad3d32 /src/WixToolset.Core | |
| parent | 860f77f7c9d522074dc7e44cfe11281efd20687f (diff) | |
| download | wix-86e59fdbc94ae661ca682f04cddb60d7830ae8a8.tar.gz wix-86e59fdbc94ae661ca682f04cddb60d7830ae8a8.tar.bz2 wix-86e59fdbc94ae661ca682f04cddb60d7830ae8a8.zip | |
Introduce StandardDirectory for referencing standard directories
Completes wixtoolset/issues#6416
Diffstat (limited to 'src/WixToolset.Core')
| -rw-r--r-- | src/WixToolset.Core/Compiler.cs | 72 | ||||
| -rw-r--r-- | src/WixToolset.Core/CompilerWarnings.cs | 12 | ||||
| -rw-r--r-- | src/WixToolset.Core/Compiler_Module.cs | 3 | ||||
| -rw-r--r-- | src/WixToolset.Core/Compiler_Package.cs | 3 |
4 files changed, 90 insertions, 0 deletions
diff --git a/src/WixToolset.Core/Compiler.cs b/src/WixToolset.Core/Compiler.cs index 184c5b3e..ca9385f6 100644 --- a/src/WixToolset.Core/Compiler.cs +++ b/src/WixToolset.Core/Compiler.cs | |||
| @@ -4427,6 +4427,10 @@ namespace WixToolset.Core | |||
| 4427 | { | 4427 | { |
| 4428 | this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id")); | 4428 | this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id")); |
| 4429 | } | 4429 | } |
| 4430 | else if (WindowsInstallerStandard.IsStandardDirectory(id)) | ||
| 4431 | { | ||
| 4432 | this.Core.Write(CompilerWarnings.DirectoryRefStandardDirectoryDeprecated(sourceLineNumbers, id)); | ||
| 4433 | } | ||
| 4430 | 4434 | ||
| 4431 | if (!String.IsNullOrEmpty(fileSource) && !fileSource.EndsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal)) | 4435 | if (!String.IsNullOrEmpty(fileSource) && !fileSource.EndsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal)) |
| 4432 | { | 4436 | { |
| @@ -6324,6 +6328,9 @@ namespace WixToolset.Core | |||
| 6324 | string parentName = null; | 6328 | string parentName = null; |
| 6325 | this.ParseSFPCatalogElement(child, ref parentName); | 6329 | this.ParseSFPCatalogElement(child, ref parentName); |
| 6326 | break; | 6330 | break; |
| 6331 | case "StandardDirectory": | ||
| 6332 | this.ParseStandardDirectoryElement(child); | ||
| 6333 | break; | ||
| 6327 | case "UI": | 6334 | case "UI": |
| 6328 | this.ParseUIElement(child); | 6335 | this.ParseUIElement(child); |
| 6329 | break; | 6336 | break; |
| @@ -7559,6 +7566,71 @@ namespace WixToolset.Core | |||
| 7559 | } | 7566 | } |
| 7560 | 7567 | ||
| 7561 | /// <summary> | 7568 | /// <summary> |
| 7569 | /// Parses a standard directory element. | ||
| 7570 | /// </summary> | ||
| 7571 | /// <param name="node">Element to parse.</param> | ||
| 7572 | private void ParseStandardDirectoryElement(XElement node) | ||
| 7573 | { | ||
| 7574 | var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); | ||
| 7575 | string id = null; | ||
| 7576 | |||
| 7577 | foreach (var attrib in node.Attributes()) | ||
| 7578 | { | ||
| 7579 | if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) | ||
| 7580 | { | ||
| 7581 | switch (attrib.Name.LocalName) | ||
| 7582 | { | ||
| 7583 | case "Id": | ||
| 7584 | id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); | ||
| 7585 | break; | ||
| 7586 | default: | ||
| 7587 | this.Core.UnexpectedAttribute(node, attrib); | ||
| 7588 | break; | ||
| 7589 | } | ||
| 7590 | } | ||
| 7591 | else | ||
| 7592 | { | ||
| 7593 | this.Core.ParseExtensionAttribute(node, attrib); | ||
| 7594 | } | ||
| 7595 | } | ||
| 7596 | |||
| 7597 | if (String.IsNullOrEmpty(id)) | ||
| 7598 | { | ||
| 7599 | this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id")); | ||
| 7600 | } | ||
| 7601 | else if (!WindowsInstallerStandard.IsStandardDirectory(id)) | ||
| 7602 | { | ||
| 7603 | this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "Id", id, String.Join(", \"", WindowsInstallerStandard.StandardDirectories().Select(d => d.Id.Id)))); | ||
| 7604 | } | ||
| 7605 | |||
| 7606 | foreach (var child in node.Elements()) | ||
| 7607 | { | ||
| 7608 | if (CompilerCore.WixNamespace == child.Name.Namespace) | ||
| 7609 | { | ||
| 7610 | switch (child.Name.LocalName) | ||
| 7611 | { | ||
| 7612 | case "Component": | ||
| 7613 | this.ParseComponentElement(child, ComplexReferenceParentType.Unknown, null, null, diskId: CompilerConstants.IntegerNotSet, id, srcPath: String.Empty); | ||
| 7614 | break; | ||
| 7615 | case "Directory": | ||
| 7616 | this.ParseDirectoryElement(child, id, diskId: CompilerConstants.IntegerNotSet, fileSource: String.Empty); | ||
| 7617 | break; | ||
| 7618 | case "Merge": | ||
| 7619 | this.ParseMergeElement(child, id, diskId: CompilerConstants.IntegerNotSet); | ||
| 7620 | break; | ||
| 7621 | default: | ||
| 7622 | this.Core.UnexpectedElement(node, child); | ||
| 7623 | break; | ||
| 7624 | } | ||
| 7625 | } | ||
| 7626 | else | ||
| 7627 | { | ||
| 7628 | this.Core.ParseExtensionElement(node, child); | ||
| 7629 | } | ||
| 7630 | } | ||
| 7631 | } | ||
| 7632 | |||
| 7633 | /// <summary> | ||
| 7562 | /// Parses a configuration data element. | 7634 | /// Parses a configuration data element. |
| 7563 | /// </summary> | 7635 | /// </summary> |
| 7564 | /// <param name="node">Element to parse.</param> | 7636 | /// <param name="node">Element to parse.</param> |
diff --git a/src/WixToolset.Core/CompilerWarnings.cs b/src/WixToolset.Core/CompilerWarnings.cs index 3b9666dd..eb838ae2 100644 --- a/src/WixToolset.Core/CompilerWarnings.cs +++ b/src/WixToolset.Core/CompilerWarnings.cs | |||
| @@ -6,6 +6,16 @@ namespace WixToolset.Core | |||
| 6 | 6 | ||
| 7 | internal static class CompilerWarnings | 7 | internal static class CompilerWarnings |
| 8 | { | 8 | { |
| 9 | public static Message DirectoryRefStandardDirectoryDeprecated(SourceLineNumber sourceLineNumbers, string directoryId) | ||
| 10 | { | ||
| 11 | return Message(sourceLineNumbers, Ids.DirectoryRefStandardDirectoryDeprecated, "Using DirectoryRef to reference the standard directory '{0}' is deprecated. Use the StandardDirectory element instead.", directoryId); | ||
| 12 | } | ||
| 13 | |||
| 14 | public static Message DefiningStandardDirectoryDeprecated(SourceLineNumber sourceLineNumbers, string directoryId) | ||
| 15 | { | ||
| 16 | return Message(sourceLineNumbers, Ids.DefiningStandardDirectoryDeprecated, "It is no longer necessary to define the standard directory '{0}'. Use the StandardDirectory element instead.", directoryId); | ||
| 17 | } | ||
| 18 | |||
| 9 | public static Message DiscouragedVersionAttribute(SourceLineNumber sourceLineNumbers) | 19 | public static Message DiscouragedVersionAttribute(SourceLineNumber sourceLineNumbers) |
| 10 | { | 20 | { |
| 11 | return Message(sourceLineNumbers, Ids.DiscouragedVersionAttribute, "The Provides/@Version attribute should not be specified in an MSI package. The ProductVersion will be used by default."); | 21 | return Message(sourceLineNumbers, Ids.DiscouragedVersionAttribute, "The Provides/@Version attribute should not be specified in an MSI package. The ProductVersion will be used by default."); |
| @@ -48,6 +58,8 @@ namespace WixToolset.Core | |||
| 48 | PropertyRemoved = 5433, | 58 | PropertyRemoved = 5433, |
| 49 | DiscouragedVersionAttribute = 5434, | 59 | DiscouragedVersionAttribute = 5434, |
| 50 | Win64Component = 5435, | 60 | Win64Component = 5435, |
| 61 | DirectoryRefStandardDirectoryDeprecated = 5436, | ||
| 62 | DefiningStandardDirectoryDeprecated = 5437, | ||
| 51 | } | 63 | } |
| 52 | } | 64 | } |
| 53 | } | 65 | } |
diff --git a/src/WixToolset.Core/Compiler_Module.cs b/src/WixToolset.Core/Compiler_Module.cs index 59fe9164..3986c8da 100644 --- a/src/WixToolset.Core/Compiler_Module.cs +++ b/src/WixToolset.Core/Compiler_Module.cs | |||
| @@ -203,6 +203,9 @@ namespace WixToolset.Core | |||
| 203 | string parentName = null; | 203 | string parentName = null; |
| 204 | this.ParseSFPCatalogElement(child, ref parentName); | 204 | this.ParseSFPCatalogElement(child, ref parentName); |
| 205 | break; | 205 | break; |
| 206 | case "StandardDirectory": | ||
| 207 | this.ParseStandardDirectoryElement(child); | ||
| 208 | break; | ||
| 206 | case "Substitution": | 209 | case "Substitution": |
| 207 | this.ParseSubstitutionElement(child); | 210 | this.ParseSubstitutionElement(child); |
| 208 | break; | 211 | break; |
diff --git a/src/WixToolset.Core/Compiler_Package.cs b/src/WixToolset.Core/Compiler_Package.cs index 576450f4..f9d77873 100644 --- a/src/WixToolset.Core/Compiler_Package.cs +++ b/src/WixToolset.Core/Compiler_Package.cs | |||
| @@ -316,6 +316,9 @@ namespace WixToolset.Core | |||
| 316 | case "SoftwareTag": | 316 | case "SoftwareTag": |
| 317 | this.ParsePackageTagElement(child); | 317 | this.ParsePackageTagElement(child); |
| 318 | break; | 318 | break; |
| 319 | case "StandardDirectory": | ||
| 320 | this.ParseStandardDirectoryElement(child); | ||
| 321 | break; | ||
| 319 | case "SummaryInformation": | 322 | case "SummaryInformation": |
| 320 | this.ParseSummaryInformationElement(child, ref isCodepageSet, ref isPackageNameSet, ref isKeywordsSet, ref isPackageAuthorSet); | 323 | this.ParseSummaryInformationElement(child, ref isCodepageSet, ref isPackageNameSet, ref isKeywordsSet, ref isPackageAuthorSet); |
| 321 | break; | 324 | break; |
