microsoft / azure-pipelines-tasks

Tasks for Azure Pipelines
https://aka.ms/tfbuild
MIT License
3.47k stars 2.6k forks source link

[BUG]: UseDotNet task installs x86 build on Windows arm64 #20300

Open azchohfi opened 4 weeks ago

azchohfi commented 4 weeks ago

New issue checklist

Task name

UseDotNet

Task version

2

Issue Description

My host is an Arm64 machine, but it trying to install the x86 version of the dotnet sdk.

Environment type (Please select at least one enviroment where you face this issue)

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

No response

Operation system

Windows 2022 ARM64

Relevant log output

Tool to install: .NET Core sdk version 8.0.x.
Found version 8.0.400 in channel 8.0 for user specified version spec: 8.0.x
Version 8.0.400 was not found in cache.
Getting URL to download .NET Core sdk version: 8.0.400.
Detecting OS platform to find correct download package for the OS.
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "& 'C:\a\_work\_tasks\UseDotNet_b0ce7256-7898-45d3-9cb5-176b752bfea6\2.243.1\externals\get-os-platform.ps1'"
Primary:win-x86
Detected platform (Primary): win-x86
Downloading: https://download.visualstudio.microsoft.com/download/pr/4bc6c939-8cb1-45c4-afde-a1b0715eec7d/c3835988860504c59187049089ca2466/dotnet-sdk-8.0.400-win-x86.zip
Extracting downloaded package C:\a\_work\_temp\1b29a698-0d9b-40f8-837e-492b74a90b1f.
Extracting archive
C:\Windows\system32\chcp.com 65001
Active code page: 65001

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('C:\a\_work\_temp\1b29a698-0d9b-40f8-837e-492b74a90b1f', 'C:\a\_work\_temp\99cb')"

Successfully installed .NET Core sdk version 8.0.400.
Creating global tool path and pre-pending to PATH.

Full task logs with system.debug enabled

 [REPLACE THIS WITH YOUR INFORMATION] 

Repro steps

- task: UseDotNet@2
  displayName: Setup .NET 8
  inputs:
    version: 8.0.x
azchohfi commented 4 weeks ago

This seems to be missing arm64: https://github.com/microsoft/azure-pipelines-tasks/blob/a3c064aaffa164e48da873e564de7022ac5d82d3/Tasks/UseDotNetV2/externals/get-os-platform.ps1#L11-L12 But weirdly it went the x86 code path.

aleksandrlevochkin commented 3 weeks ago

Hi @azchohfi thank you for reporting this issue. As I see, the script determines the architecture by checking the env variable PROCESSOR_ARCHITECTURE. It seems like this variable does not necessarily return the actual architecture of the processor but of the process with this env variable.

Is there any chance that you're using the x86 version of the self-hosted agent?