@joebigelow / wix-1 / commits / e6ef75f3

Log error when path to executable cannot be found in MSBuild tool task

This is additional logging to try to track down the root cause of 7035.

Rob Mensching committed Nov 20, 2022 at 14:59 UTC e6ef75f3616f1221a43e3b412b42f9ca6a2bef7e
2 files changed +36 -13
src/internal/WixInternal.BaseBuildTasks.Sources/BaseToolsetTask.cs
+35 -12
@@ -3,6 +3,7 @@
3 namespace WixToolset.BaseBuildTasks
4 {
5 using System;
6 + using System.Collections.Generic;
7 using System.IO;
8 using System.Runtime.InteropServices;
9 using Microsoft.Build.Utilities;
@@ -129,24 +130,48 @@ namespace WixToolset.BaseBuildTasks
130 return false;
131 }
132 #else
132 - private static string GetArchitectureFolder(string baseFolder)
133 + private string FindArchitectureSpecificToolPath(string baseFolder)
134 {
135 + var checkedPaths = new List<string>();
136 +
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);
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))
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);
160 }
161
142 - // Try to fallback to "x86" folder.
143 - if (folder != "x86" && Directory.Exists(Path.Combine(baseFolder, "x86")))
162 + // Return empty, even though this isn't likely to be there.
163 + path = Path.Combine(baseFolder, this.ToolExe);
164 +
165 + if (File.Exists(path))
166 {
145 - return "x86";
167 + return path;
168 }
169
148 - // Return empty, even though this isn't likely to be useful.
149 - return String.Empty;
170 + checkedPaths.Add(path);
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;
175 }
176 #endif
177
@@ -159,9 +184,7 @@ namespace WixToolset.BaseBuildTasks
184 #else
185 var thisTaskFolder = Path.GetDirectoryName(new Uri(typeof(BaseToolsetTask).Assembly.CodeBase).AbsolutePath);
186
162 - var archFolder = GetArchitectureFolder(thisTaskFolder);
163 -
164 - return Path.Combine(thisTaskFolder, archFolder, this.ToolExe);
187 + return this.FindArchitectureSpecificToolPath(thisTaskFolder);
188 #endif
189 }
190
src/wix/WixToolset.BuildTasks/ReadTracking.cs
+1 -1
@@ -93,7 +93,7 @@ namespace WixToolset.BuildTasks
93 }
94 else
95 {
96 - this.Log.LogError($"Failed to parse tracked line: {line}");
96 + this.Log.LogError("Failed to parse tracked line: {0}", line);
97 }
98 }
99 }