aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2024-07-12 01:25:29 -0700
committerRob Mensching <rob@firegiant.com>2024-07-15 15:21:20 -0700
commit4c1410d13b18e0f1ace6afd62cc10e2ff4a98216 (patch)
tree389337a673b7279eb58dc80d0460a4c011b6d520
parentb5de0c02c811549d5e15bfc209a1fa9c1f1744d2 (diff)
downloadwix-4c1410d13b18e0f1ace6afd62cc10e2ff4a98216.tar.gz
wix-4c1410d13b18e0f1ace6afd62cc10e2ff4a98216.tar.bz2
wix-4c1410d13b18e0f1ace6afd62cc10e2ff4a98216.zip
Fix "wix extension list" to correctly display machine-wide extensions
Fixes 8625
-rw-r--r--src/wix/WixToolset.Core.ExtensionCache/ExtensionCacheManager.cs77
1 files changed, 46 insertions, 31 deletions
diff --git a/src/wix/WixToolset.Core.ExtensionCache/ExtensionCacheManager.cs b/src/wix/WixToolset.Core.ExtensionCache/ExtensionCacheManager.cs
index 28aeae93..cf40b282 100644
--- a/src/wix/WixToolset.Core.ExtensionCache/ExtensionCacheManager.cs
+++ b/src/wix/WixToolset.Core.ExtensionCache/ExtensionCacheManager.cs
@@ -83,51 +83,54 @@ namespace WixToolset.Core.ExtensionCache
83 83
84 (var extensionId, var extensionVersion) = ParseExtensionReference(extension); 84 (var extensionId, var extensionVersion) = ParseExtensionReference(extension);
85 85
86 var cacheFolder = this.GetCacheFolder(global); 86 var cacheFolders = this.GetCacheFolders(global);
87
88 var searchFolder = Path.Combine(cacheFolder, extensionId, extensionVersion);
89 87
90 if (!Directory.Exists(searchFolder)) 88 foreach (var cacheFolder in cacheFolders)
91 {
92 }
93 else if (!String.IsNullOrEmpty(extensionVersion)) // looking for an explicit version of an extension.
94 { 89 {
95 var present = this.ExtensionFileExists(cacheFolder, extensionId, extensionVersion); 90 var searchFolder = Path.Combine(cacheFolder, extensionId, extensionVersion);
96 found.Add(new CachedExtension(extensionId, extensionVersion, !present));
97 }
98 else // looking for all versions of an extension or all versions of all extensions.
99 {
100 IEnumerable<string> foundExtensionIds;
101 91
102 if (String.IsNullOrEmpty(extensionId)) 92 if (!Directory.Exists(searchFolder))
103 { 93 {
104 // Looking for all versions of all extensions.
105 foundExtensionIds = Directory.GetDirectories(cacheFolder).Select(folder => Path.GetFileName(folder)).ToList();
106 } 94 }
107 else 95 else if (!String.IsNullOrEmpty(extensionVersion)) // looking for an explicit version of an extension.
108 { 96 {
109 // Looking for all versions of a single extension. 97 var present = this.ExtensionFileExists(cacheFolder, extensionId, extensionVersion);
110 var extensionFolder = Path.Combine(cacheFolder, extensionId); 98 found.Add(new CachedExtension(extensionId, extensionVersion, !present));
111 foundExtensionIds = Directory.Exists(extensionFolder) ? new[] { extensionId } : Array.Empty<string>();
112 } 99 }
113 100 else // looking for all versions of an extension or all versions of all extensions.
114 foreach (var foundExtensionId in foundExtensionIds)
115 { 101 {
116 var extensionFolder = Path.Combine(cacheFolder, foundExtensionId); 102 IEnumerable<string> foundExtensionIds;
117 103
118 foreach (var folder in Directory.GetDirectories(extensionFolder)) 104 if (String.IsNullOrEmpty(extensionId))
105 {
106 // Looking for all versions of all extensions.
107 foundExtensionIds = Directory.GetDirectories(cacheFolder).Select(folder => Path.GetFileName(folder)).ToList();
108 }
109 else
119 { 110 {
120 cancellationToken.ThrowIfCancellationRequested(); 111 // Looking for all versions of a single extension.
112 var extensionFolder = Path.Combine(cacheFolder, extensionId);
113 foundExtensionIds = Directory.Exists(extensionFolder) ? new[] { extensionId } : Array.Empty<string>();
114 }
121 115
122 var foundExtensionVersion = Path.GetFileName(folder); 116 foreach (var foundExtensionId in foundExtensionIds)
117 {
118 var extensionFolder = Path.Combine(cacheFolder, foundExtensionId);
123 119
124 if (!NuGetVersion.TryParse(foundExtensionVersion, out _)) 120 foreach (var foundExtensionVersionFolder in Directory.GetDirectories(extensionFolder))
125 { 121 {
126 continue; 122 cancellationToken.ThrowIfCancellationRequested();
127 } 123
124 var foundExtensionVersion = Path.GetFileName(foundExtensionVersionFolder);
128 125
129 var present = this.ExtensionFileExists(cacheFolder, foundExtensionId, foundExtensionVersion); 126 if (!NuGetVersion.TryParse(foundExtensionVersion, out _))
130 found.Add(new CachedExtension(foundExtensionId, foundExtensionVersion, !present)); 127 {
128 continue;
129 }
130
131 var present = this.ExtensionFileExists(cacheFolder, foundExtensionId, foundExtensionVersion);
132 found.Add(new CachedExtension(foundExtensionId, foundExtensionVersion, !present));
133 }
131 } 134 }
132 } 135 }
133 } 136 }
@@ -149,6 +152,18 @@ namespace WixToolset.Core.ExtensionCache
149 return cacheLocation.Path; 152 return cacheLocation.Path;
150 } 153 }
151 154
155 private IEnumerable<string> GetCacheFolders(bool global)
156 {
157 if (this.cacheLocations == null)
158 {
159 this.cacheLocations = this.ExtensionManager.GetCacheLocations();
160 }
161
162 var cacheLocations = this.cacheLocations.Where(l => global || l.Scope == ExtensionCacheLocationScope.Project).OrderBy(l => l.Scope).Select(l => l.Path);
163
164 return cacheLocations;
165 }
166
152 private async Task<bool> DownloadAndExtractAsync(bool global, string id, string version, CancellationToken cancellationToken) 167 private async Task<bool> DownloadAndExtractAsync(bool global, string id, string version, CancellationToken cancellationToken)
153 { 168 {
154 var logger = NullLogger.Instance; 169 var logger = NullLogger.Instance;