aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core/ExtensibilityServices/PathResolver.cs
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2020-07-21 14:31:53 -0700
committerRob Mensching <rob@firegiant.com>2020-07-21 14:41:12 -0700
commitb62a7a0beb7ceb7987de28ec768c7814cadb83b9 (patch)
tree69a9183a3182334f0d48a39ab8e411ee3fc3aecd /src/WixToolset.Core/ExtensibilityServices/PathResolver.cs
parent414c07f7adce9c9fd0132ab0fade0267f743f665 (diff)
downloadwix-b62a7a0beb7ceb7987de28ec768c7814cadb83b9.tar.gz
wix-b62a7a0beb7ceb7987de28ec768c7814cadb83b9.tar.bz2
wix-b62a7a0beb7ceb7987de28ec768c7814cadb83b9.zip
Support implicit standard directory reference and "3264" platform folders
Completes wixtoolset/issues#5798 and wixtoolset/issues#5835
Diffstat (limited to 'src/WixToolset.Core/ExtensibilityServices/PathResolver.cs')
-rw-r--r--src/WixToolset.Core/ExtensibilityServices/PathResolver.cs51
1 files changed, 39 insertions, 12 deletions
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
12 12
13 internal class PathResolver : IPathResolver 13 internal class PathResolver : IPathResolver
14 { 14 {
15 public string GetDirectoryPath(Dictionary<string, IResolvedDirectory> directories, Dictionary<string, string> componentIdGenSeeds, string directory, bool canonicalize) 15 public string GetCanonicalDirectoryPath(Dictionary<string, IResolvedDirectory> directories, Dictionary<string, string> componentIdGenSeeds, string directory, Platform platform)
16 { 16 {
17 if (!directories.TryGetValue(directory, out var resolvedDirectory)) 17 if (!directories.TryGetValue(directory, out var resolvedDirectory))
18 { 18 {
@@ -25,19 +25,13 @@ namespace WixToolset.Core.ExtensibilityServices
25 { 25 {
26 resolvedDirectory.Path = componentIdGenSeeds[directory]; 26 resolvedDirectory.Path = componentIdGenSeeds[directory];
27 } 27 }
28 else if (canonicalize && WindowsInstallerStandard.IsStandardDirectory(directory)) 28 else if (WindowsInstallerStandard.IsStandardDirectory(directory))
29 { 29 {
30 // when canonicalization is on, standard directories are treated equally 30 resolvedDirectory.Path = WindowsInstallerStandard.GetPlatformSpecificDirectoryId(directory, platform);
31 resolvedDirectory.Path = directory;
32 } 31 }
33 else 32 else
34 { 33 {
35 string name = resolvedDirectory.Name; 34 var name = resolvedDirectory.Name?.ToLowerInvariant();
36
37 if (canonicalize)
38 {
39 name = name?.ToLowerInvariant();
40 }
41 35
42 if (String.IsNullOrEmpty(resolvedDirectory.DirectoryParent)) 36 if (String.IsNullOrEmpty(resolvedDirectory.DirectoryParent))
43 { 37 {
@@ -45,7 +39,7 @@ namespace WixToolset.Core.ExtensibilityServices
45 } 39 }
46 else 40 else
47 { 41 {
48 var parentPath = this.GetDirectoryPath(directories, componentIdGenSeeds, resolvedDirectory.DirectoryParent, canonicalize); 42 var parentPath = this.GetCanonicalDirectoryPath(directories, componentIdGenSeeds, resolvedDirectory.DirectoryParent, platform);
49 43
50 if (null != resolvedDirectory.Name) 44 if (null != resolvedDirectory.Name)
51 { 45 {
@@ -62,6 +56,39 @@ namespace WixToolset.Core.ExtensibilityServices
62 return resolvedDirectory.Path; 56 return resolvedDirectory.Path;
63 } 57 }
64 58
59 public string GetDirectoryPath(Dictionary<string, IResolvedDirectory> directories, string directory)
60 {
61 if (!directories.TryGetValue(directory, out var resolvedDirectory))
62 {
63 throw new WixException(ErrorMessages.ExpectedDirectory(directory));
64 }
65
66 if (null == resolvedDirectory.Path)
67 {
68 var name = resolvedDirectory.Name;
69
70 if (String.IsNullOrEmpty(resolvedDirectory.DirectoryParent))
71 {
72 resolvedDirectory.Path = name;
73 }
74 else
75 {
76 var parentPath = this.GetDirectoryPath(directories, resolvedDirectory.DirectoryParent);
77
78 if (null != resolvedDirectory.Name)
79 {
80 resolvedDirectory.Path = Path.Combine(parentPath, name);
81 }
82 else
83 {
84 resolvedDirectory.Path = parentPath;
85 }
86 }
87 }
88
89 return resolvedDirectory.Path;
90 }
91
65 public string GetFileSourcePath(Dictionary<string, IResolvedDirectory> directories, string directoryId, string fileName, bool compressed, bool useLongName) 92 public string GetFileSourcePath(Dictionary<string, IResolvedDirectory> directories, string directoryId, string fileName, bool compressed, bool useLongName)
66 { 93 {
67 var fileSourcePath = Common.GetName(fileName, true, useLongName); 94 var fileSourcePath = Common.GetName(fileName, true, useLongName);
@@ -75,7 +102,7 @@ namespace WixToolset.Core.ExtensibilityServices
75 { 102 {
76 // Get the relative path of where we want the file to be layed out as specified 103 // Get the relative path of where we want the file to be layed out as specified
77 // in the Directory table. 104 // in the Directory table.
78 var directoryPath = this.GetDirectoryPath(directories, null, directoryId, false); 105 var directoryPath = this.GetDirectoryPath(directories, directoryId);
79 fileSourcePath = Path.Combine(directoryPath, fileSourcePath); 106 fileSourcePath = Path.Combine(directoryPath, fileSourcePath);
80 } 107 }
81 108