From b62a7a0beb7ceb7987de28ec768c7814cadb83b9 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Tue, 21 Jul 2020 14:31:53 -0700 Subject: Support implicit standard directory reference and "3264" platform folders Completes wixtoolset/issues#5798 and wixtoolset/issues#5835 --- .../ExtensibilityServices/PathResolver.cs | 51 +++++++++++++++++----- 1 file changed, 39 insertions(+), 12 deletions(-) (limited to 'src/WixToolset.Core/ExtensibilityServices/PathResolver.cs') diff --git a/src/WixToolset.Core/ExtensibilityServices/PathResolver.cs b/src/WixToolset.Core/ExtensibilityServices/PathResolver.cs index 15cd4fc9..72be2bcb 100644 --- a/src/WixToolset.Core/ExtensibilityServices/PathResolver.cs +++ b/src/WixToolset.Core/ExtensibilityServices/PathResolver.cs @@ -12,7 +12,7 @@ namespace WixToolset.Core.ExtensibilityServices internal class PathResolver : IPathResolver { - public string GetDirectoryPath(Dictionary directories, Dictionary componentIdGenSeeds, string directory, bool canonicalize) + public string GetCanonicalDirectoryPath(Dictionary directories, Dictionary componentIdGenSeeds, string directory, Platform platform) { if (!directories.TryGetValue(directory, out var resolvedDirectory)) { @@ -25,19 +25,13 @@ namespace WixToolset.Core.ExtensibilityServices { resolvedDirectory.Path = componentIdGenSeeds[directory]; } - else if (canonicalize && WindowsInstallerStandard.IsStandardDirectory(directory)) + else if (WindowsInstallerStandard.IsStandardDirectory(directory)) { - // when canonicalization is on, standard directories are treated equally - resolvedDirectory.Path = directory; + resolvedDirectory.Path = WindowsInstallerStandard.GetPlatformSpecificDirectoryId(directory, platform); } else { - string name = resolvedDirectory.Name; - - if (canonicalize) - { - name = name?.ToLowerInvariant(); - } + var name = resolvedDirectory.Name?.ToLowerInvariant(); if (String.IsNullOrEmpty(resolvedDirectory.DirectoryParent)) { @@ -45,7 +39,7 @@ namespace WixToolset.Core.ExtensibilityServices } else { - var parentPath = this.GetDirectoryPath(directories, componentIdGenSeeds, resolvedDirectory.DirectoryParent, canonicalize); + var parentPath = this.GetCanonicalDirectoryPath(directories, componentIdGenSeeds, resolvedDirectory.DirectoryParent, platform); if (null != resolvedDirectory.Name) { @@ -62,6 +56,39 @@ namespace WixToolset.Core.ExtensibilityServices return resolvedDirectory.Path; } + public string GetDirectoryPath(Dictionary directories, string directory) + { + if (!directories.TryGetValue(directory, out var resolvedDirectory)) + { + throw new WixException(ErrorMessages.ExpectedDirectory(directory)); + } + + if (null == resolvedDirectory.Path) + { + var name = resolvedDirectory.Name; + + if (String.IsNullOrEmpty(resolvedDirectory.DirectoryParent)) + { + resolvedDirectory.Path = name; + } + else + { + var parentPath = this.GetDirectoryPath(directories, resolvedDirectory.DirectoryParent); + + if (null != resolvedDirectory.Name) + { + resolvedDirectory.Path = Path.Combine(parentPath, name); + } + else + { + resolvedDirectory.Path = parentPath; + } + } + } + + return resolvedDirectory.Path; + } + public string GetFileSourcePath(Dictionary directories, string directoryId, string fileName, bool compressed, bool useLongName) { var fileSourcePath = Common.GetName(fileName, true, useLongName); @@ -75,7 +102,7 @@ namespace WixToolset.Core.ExtensibilityServices { // Get the relative path of where we want the file to be layed out as specified // in the Directory table. - var directoryPath = this.GetDirectoryPath(directories, null, directoryId, false); + var directoryPath = this.GetDirectoryPath(directories, directoryId); fileSourcePath = Path.Combine(directoryPath, fileSourcePath); } -- cgit v1.2.3-55-g6feb