From c5950dc4a5f000076652e70dcc3480b2b138acf5 Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Tue, 26 Nov 2024 19:16:49 +0100 Subject: [PATCH 1/8] Update detection of OS Architecture --- .../UseDotNetV2/externals/get-os-platform.ps1 | 43 +++++++++++++++---- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/Tasks/UseDotNetV2/externals/get-os-platform.ps1 b/Tasks/UseDotNetV2/externals/get-os-platform.ps1 index 4ac8d07f5ba4..3ea42328322c 100644 --- a/Tasks/UseDotNetV2/externals/get-os-platform.ps1 +++ b/Tasks/UseDotNetV2/externals/get-os-platform.ps1 @@ -1,16 +1,43 @@ -function Get-Machine-Architecture() -{ - # possible values: AMD64, IA64, x86 +function Get-Machine-Architecture() { + Say-Invocation $MyInvocation + + # 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).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) { + Say-Invocation $MyInvocation + + if ($Architecture -eq "") { + $Architecture = Get-Machine-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/dotnet/install-scripts/issues" } } } From eff20aa18a242663ca497a6b1ece4112a14ef39c Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Tue, 26 Nov 2024 19:28:41 +0100 Subject: [PATCH 2/8] Increase version number --- Tasks/UseDotNetV2/task.json | 2 +- Tasks/UseDotNetV2/task.loc.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Tasks/UseDotNetV2/task.json b/Tasks/UseDotNetV2/task.json index 0e6ffc8e4387..42690ad70734 100644 --- a/Tasks/UseDotNetV2/task.json +++ b/Tasks/UseDotNetV2/task.json @@ -13,7 +13,7 @@ "author": "Microsoft Corporation", "version": { "Major": 2, - "Minor": 243, + "Minor": 249, "Patch": 0 }, "satisfies": [ diff --git a/Tasks/UseDotNetV2/task.loc.json b/Tasks/UseDotNetV2/task.loc.json index f413cdd3c194..a2d65ac05043 100644 --- a/Tasks/UseDotNetV2/task.loc.json +++ b/Tasks/UseDotNetV2/task.loc.json @@ -13,7 +13,7 @@ "author": "Microsoft Corporation", "version": { "Major": 2, - "Minor": 243, + "Minor": 249, "Patch": 0 }, "satisfies": [ From 3057335be951efd991144c0707d52f0c3216a187 Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Tue, 26 Nov 2024 19:40:33 +0100 Subject: [PATCH 3/8] Improvements --- Tasks/UseDotNetV2/externals/get-os-platform.ps1 | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/Tasks/UseDotNetV2/externals/get-os-platform.ps1 b/Tasks/UseDotNetV2/externals/get-os-platform.ps1 index 3ea42328322c..8d515dcfd178 100644 --- a/Tasks/UseDotNetV2/externals/get-os-platform.ps1 +++ b/Tasks/UseDotNetV2/externals/get-os-platform.ps1 @@ -1,6 +1,4 @@ function Get-Machine-Architecture() { - Say-Invocation $MyInvocation - # 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. @@ -10,7 +8,7 @@ function Get-Machine-Architecture() { } try { - if( ((Get-CimInstance -ClassName CIM_OperatingSystem).OSArchitecture) -like "ARM*") { + if( ((Get-CimInstance -ClassName CIM_OperatingSystem -OperationTimeoutSec 30).OSArchitecture) -like "ARM*") { if( [Environment]::Is64BitOperatingSystem ) { return "arm64" @@ -26,12 +24,6 @@ function Get-Machine-Architecture() { } function Get-CLIArchitecture-From-Architecture([string]$Architecture) { - Say-Invocation $MyInvocation - - if ($Architecture -eq "") { - $Architecture = Get-Machine-Architecture - } - switch ($Architecture.ToLowerInvariant()) { { ($_ -eq "amd64") -or ($_ -eq "x64") } { return "x64" } { $_ -eq "x86" } { return "x86" } From 64d3ee16cbc815657c9489c81c587757277dbecf Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Tue, 26 Nov 2024 19:42:14 +0100 Subject: [PATCH 4/8] Adjust issues link --- Tasks/UseDotNetV2/externals/get-os-platform.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tasks/UseDotNetV2/externals/get-os-platform.ps1 b/Tasks/UseDotNetV2/externals/get-os-platform.ps1 index 8d515dcfd178..f6153539d2b4 100644 --- a/Tasks/UseDotNetV2/externals/get-os-platform.ps1 +++ b/Tasks/UseDotNetV2/externals/get-os-platform.ps1 @@ -29,7 +29,7 @@ function Get-CLIArchitecture-From-Architecture([string]$Architecture) { { $_ -eq "x86" } { return "x86" } { $_ -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/dotnet/install-scripts/issues" } + default { throw "Architecture '$Architecture' not supported. If you think this is a bug, report it at https://github.com/microsoft/azure-pipelines-tasks/issues" } } } From 303e9fe346256b3a7a7f0abea959dc54601bfe68 Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Tue, 26 Nov 2024 19:16:49 +0100 Subject: [PATCH 5/8] Update detection of OS Architecture --- .../UseDotNetV2/externals/get-os-platform.ps1 | 43 +++++++++++++++---- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/Tasks/UseDotNetV2/externals/get-os-platform.ps1 b/Tasks/UseDotNetV2/externals/get-os-platform.ps1 index 4ac8d07f5ba4..3ea42328322c 100644 --- a/Tasks/UseDotNetV2/externals/get-os-platform.ps1 +++ b/Tasks/UseDotNetV2/externals/get-os-platform.ps1 @@ -1,16 +1,43 @@ -function Get-Machine-Architecture() -{ - # possible values: AMD64, IA64, x86 +function Get-Machine-Architecture() { + Say-Invocation $MyInvocation + + # 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).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) { + Say-Invocation $MyInvocation + + if ($Architecture -eq "") { + $Architecture = Get-Machine-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/dotnet/install-scripts/issues" } } } From 140f59cbdb37ac7d7e3c3706063bb2f935e49d74 Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Tue, 26 Nov 2024 19:28:41 +0100 Subject: [PATCH 6/8] Increase version number --- Tasks/UseDotNetV2/task.json | 2 +- Tasks/UseDotNetV2/task.loc.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Tasks/UseDotNetV2/task.json b/Tasks/UseDotNetV2/task.json index 7ab9cc97a88b..aaecd4d3fedb 100644 --- a/Tasks/UseDotNetV2/task.json +++ b/Tasks/UseDotNetV2/task.json @@ -13,7 +13,7 @@ "author": "Microsoft Corporation", "version": { "Major": 2, - "Minor": 248, + "Minor": 249, "Patch": 0 }, "satisfies": [ diff --git a/Tasks/UseDotNetV2/task.loc.json b/Tasks/UseDotNetV2/task.loc.json index 65944cef02c9..c5378f9766b2 100644 --- a/Tasks/UseDotNetV2/task.loc.json +++ b/Tasks/UseDotNetV2/task.loc.json @@ -13,7 +13,7 @@ "author": "Microsoft Corporation", "version": { "Major": 2, - "Minor": 248, + "Minor": 249, "Patch": 0 }, "satisfies": [ From 749076915f05c76c111ff35e46dd077d5a62c146 Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Tue, 26 Nov 2024 19:40:33 +0100 Subject: [PATCH 7/8] Improvements --- Tasks/UseDotNetV2/externals/get-os-platform.ps1 | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/Tasks/UseDotNetV2/externals/get-os-platform.ps1 b/Tasks/UseDotNetV2/externals/get-os-platform.ps1 index 3ea42328322c..8d515dcfd178 100644 --- a/Tasks/UseDotNetV2/externals/get-os-platform.ps1 +++ b/Tasks/UseDotNetV2/externals/get-os-platform.ps1 @@ -1,6 +1,4 @@ function Get-Machine-Architecture() { - Say-Invocation $MyInvocation - # 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. @@ -10,7 +8,7 @@ function Get-Machine-Architecture() { } try { - if( ((Get-CimInstance -ClassName CIM_OperatingSystem).OSArchitecture) -like "ARM*") { + if( ((Get-CimInstance -ClassName CIM_OperatingSystem -OperationTimeoutSec 30).OSArchitecture) -like "ARM*") { if( [Environment]::Is64BitOperatingSystem ) { return "arm64" @@ -26,12 +24,6 @@ function Get-Machine-Architecture() { } function Get-CLIArchitecture-From-Architecture([string]$Architecture) { - Say-Invocation $MyInvocation - - if ($Architecture -eq "") { - $Architecture = Get-Machine-Architecture - } - switch ($Architecture.ToLowerInvariant()) { { ($_ -eq "amd64") -or ($_ -eq "x64") } { return "x64" } { $_ -eq "x86" } { return "x86" } From 9b97a246b1fcbf2d08cb2f1767f5b14f2ab9587e Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Tue, 26 Nov 2024 19:42:14 +0100 Subject: [PATCH 8/8] Adjust issues link --- Tasks/UseDotNetV2/externals/get-os-platform.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tasks/UseDotNetV2/externals/get-os-platform.ps1 b/Tasks/UseDotNetV2/externals/get-os-platform.ps1 index 8d515dcfd178..f6153539d2b4 100644 --- a/Tasks/UseDotNetV2/externals/get-os-platform.ps1 +++ b/Tasks/UseDotNetV2/externals/get-os-platform.ps1 @@ -29,7 +29,7 @@ function Get-CLIArchitecture-From-Architecture([string]$Architecture) { { $_ -eq "x86" } { return "x86" } { $_ -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/dotnet/install-scripts/issues" } + default { throw "Architecture '$Architecture' not supported. If you think this is a bug, report it at https://github.com/microsoft/azure-pipelines-tasks/issues" } } }