Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update detection of OS Architecture to include ARM #20695

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
35 changes: 27 additions & 8 deletions Tasks/UseDotNetV2/externals/get-os-platform.ps1
Original file line number Diff line number Diff line change
@@ -1,16 +1,35 @@
function Get-Machine-Architecture()
{
# possible values: AMD64, IA64, x86
function Get-Machine-Architecture() {
# On PS x86, PROCESSOR_ARCHITECTURE reports x86 even on x64 systems.
# To get the correct architecture, we need to use PROCESSOR_ARCHITEW6432.
# PS x64 doesn't define this, so we fall back to PROCESSOR_ARCHITECTURE.
# Possible values: amd64, x64, x86, arm64, arm
if( $ENV:PROCESSOR_ARCHITEW6432 -ne $null ) {
return $ENV:PROCESSOR_ARCHITEW6432
}

try {
if( ((Get-CimInstance -ClassName CIM_OperatingSystem -OperationTimeoutSec 30).OSArchitecture) -like "ARM*") {
if( [Environment]::Is64BitOperatingSystem )
{
return "arm64"
}
return "arm"
}
}
catch {
# Machine doesn't support Get-CimInstance
}

return $ENV:PROCESSOR_ARCHITECTURE
}

function Get-CLIArchitecture-From-Architecture([string]$Architecture)
{
switch ($Architecture.ToLower())
{
function Get-CLIArchitecture-From-Architecture([string]$Architecture) {
switch ($Architecture.ToLowerInvariant()) {
{ ($_ -eq "amd64") -or ($_ -eq "x64") } { return "x64" }
{ $_ -eq "x86" } { return "x86" }
default { throw "Architecture not supported. If you think this is a bug, please report it at https://github.com/dotnet/cli/issues" }
{ $_ -eq "arm" } { return "arm" }
{ $_ -eq "arm64" } { return "arm64" }
default { throw "Architecture '$Architecture' not supported. If you think this is a bug, report it at https://github.com/microsoft/azure-pipelines-tasks/issues" }
}
}

Expand Down
2 changes: 1 addition & 1 deletion Tasks/UseDotNetV2/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 2,
"Minor": 248,
"Minor": 249,
"Patch": 0
},
"satisfies": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/UseDotNetV2/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 2,
"Minor": 248,
"Minor": 249,
"Patch": 0
},
"satisfies": [
Expand Down