Skip to content

Commit caec4f5

Browse files
authored
Universal Packages: Fix Artifact Tool arch detection on Linux (#624)
1 parent 2cac684 commit caec4f5

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/UniversalPackages/DownloadUniversalPackages.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,11 +355,22 @@ private void CreatePackageListJson(IReadOnlyCollection<UniversalPackage> package
355355
}
356356
else
357357
{
358-
// This isn' quite right. Really we want to use "uname -m" since that's what the artifact tool uses.
359-
artifactToolArch = Environment.GetEnvironmentVariable("HOSTTYPE")?.ToLowerInvariant();
358+
// Use "uname -m" which is equivalent to what the Azure DevOps CLI uses to determine the artifact tool arch.
359+
artifactToolArch = null;
360+
int unameExitCode = ProcessHelper.Execute(
361+
"/bin/bash",
362+
"-c \"uname -m\"",
363+
processStdOut: message => artifactToolArch = message,
364+
processStdErr: message => Log.LogError(message));
365+
if (unameExitCode != 0)
366+
{
367+
Log.LogError($"Detecting architecture (\"uname -m\") failed with exit code: {unameExitCode}.");
368+
return null;
369+
}
370+
360371
if (string.IsNullOrEmpty(artifactToolArch))
361372
{
362-
Log.LogError("Environment variable 'HOSTTYPE' was unexpectedly null");
373+
Log.LogError("Unable to detect architecture. \"uname -m\" did not emit any output.");
363374
return null;
364375
}
365376
}

0 commit comments

Comments
 (0)