diff options
Diffstat (limited to 'src/internal/WixInternal.BaseBuildTasks.Sources/BaseToolsetTask.cs')
| -rw-r--r-- | src/internal/WixInternal.BaseBuildTasks.Sources/BaseToolsetTask.cs | 47 |
1 files changed, 35 insertions, 12 deletions
diff --git a/src/internal/WixInternal.BaseBuildTasks.Sources/BaseToolsetTask.cs b/src/internal/WixInternal.BaseBuildTasks.Sources/BaseToolsetTask.cs index d9e3b5e8..6edd4a35 100644 --- a/src/internal/WixInternal.BaseBuildTasks.Sources/BaseToolsetTask.cs +++ b/src/internal/WixInternal.BaseBuildTasks.Sources/BaseToolsetTask.cs | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | namespace WixToolset.BaseBuildTasks | 3 | namespace WixToolset.BaseBuildTasks |
| 4 | { | 4 | { |
| 5 | using System; | 5 | using System; |
| 6 | using System.Collections.Generic; | ||
| 6 | using System.IO; | 7 | using System.IO; |
| 7 | using System.Runtime.InteropServices; | 8 | using System.Runtime.InteropServices; |
| 8 | using Microsoft.Build.Utilities; | 9 | using Microsoft.Build.Utilities; |
| @@ -129,24 +130,48 @@ namespace WixToolset.BaseBuildTasks | |||
| 129 | return false; | 130 | return false; |
| 130 | } | 131 | } |
| 131 | #else | 132 | #else |
| 132 | private static string GetArchitectureFolder(string baseFolder) | 133 | private string FindArchitectureSpecificToolPath(string baseFolder) |
| 133 | { | 134 | { |
| 135 | var checkedPaths = new List<string>(); | ||
| 136 | |||
| 134 | // First try to find a folder that matches this task's architecture. | 137 | // First try to find a folder that matches this task's architecture. |
| 135 | var folder = RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant(); | 138 | var archFolder = RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant(); |
| 139 | |||
| 140 | var path = Path.Combine(baseFolder, archFolder, this.ToolExe); | ||
| 141 | |||
| 142 | if (File.Exists(path)) | ||
| 143 | { | ||
| 144 | return path; | ||
| 145 | } | ||
| 146 | |||
| 147 | checkedPaths.Add(path); | ||
| 136 | 148 | ||
| 137 | if (Directory.Exists(Path.Combine(baseFolder, folder))) | 149 | // Try to fallback to "x86" folder since it tends to run on all architectures. |
| 150 | if (!String.Equals(archFolder, "x86", StringComparison.OrdinalIgnoreCase)) | ||
| 138 | { | 151 | { |
| 139 | return folder; | 152 | path = Path.Combine(baseFolder, "x86", this.ToolExe); |
| 153 | |||
| 154 | if (File.Exists(path)) | ||
| 155 | { | ||
| 156 | return path; | ||
| 157 | } | ||
| 158 | |||
| 159 | checkedPaths.Add(path); | ||
| 140 | } | 160 | } |
| 141 | 161 | ||
| 142 | // Try to fallback to "x86" folder. | 162 | // Return empty, even though this isn't likely to be there. |
| 143 | if (folder != "x86" && Directory.Exists(Path.Combine(baseFolder, "x86"))) | 163 | path = Path.Combine(baseFolder, this.ToolExe); |
| 164 | |||
| 165 | if (File.Exists(path)) | ||
| 144 | { | 166 | { |
| 145 | return "x86"; | 167 | return path; |
| 146 | } | 168 | } |
| 147 | 169 | ||
| 148 | // Return empty, even though this isn't likely to be useful. | 170 | checkedPaths.Add(path); |
| 149 | return String.Empty; | 171 | |
| 172 | this.Log.LogError("Cannot find tool executable {0} at any of the checked paths: {1}. This is unexpected and will cause later commands to fail.", this.ToolExe, String.Join(", ", checkedPaths)); | ||
| 173 | |||
| 174 | return path; | ||
| 150 | } | 175 | } |
| 151 | #endif | 176 | #endif |
| 152 | 177 | ||
| @@ -159,9 +184,7 @@ namespace WixToolset.BaseBuildTasks | |||
| 159 | #else | 184 | #else |
| 160 | var thisTaskFolder = Path.GetDirectoryName(new Uri(typeof(BaseToolsetTask).Assembly.CodeBase).AbsolutePath); | 185 | var thisTaskFolder = Path.GetDirectoryName(new Uri(typeof(BaseToolsetTask).Assembly.CodeBase).AbsolutePath); |
| 161 | 186 | ||
| 162 | var archFolder = GetArchitectureFolder(thisTaskFolder); | 187 | return this.FindArchitectureSpecificToolPath(thisTaskFolder); |
| 163 | |||
| 164 | return Path.Combine(thisTaskFolder, archFolder, this.ToolExe); | ||
| 165 | #endif | 188 | #endif |
| 166 | } | 189 | } |
| 167 | 190 | ||
