Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 22 additions & 18 deletions build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ param(

. "$PSScriptRoot\tools\buildCommon\startNativeExecution.ps1"

# CI runs with PowerShell 5.0, so don't use features like ?: && ||
Set-StrictMode -Version 3.0

# On Unix paths is separated by colon
Expand Down Expand Up @@ -861,26 +862,29 @@ function New-PSOptions {
Write-Verbose "Using framework '$Framework'"

if (-not $Runtime) {
if ($environment.IsLinux) {
$Runtime = "linux-x64"
} elseif ($environment.IsMacOS) {
if ($PSVersionTable.OS.Contains('ARM64')) {
$Runtime = "osx-arm64"
}
else {
$Runtime = "osx-x64"
$Info = dotnet --info
Write-Verbose "dotnet --info:`n${Info}"

$Platform, $Architecture = $info |
Select-String '^\s*OS Platform:\s+(\w+)$', '^\s*Architecture:\s+(\w+)$' |
Select-Object -First 2 |
ForEach-Object { $_.Matches.Groups[1].Value }

switch ($Platform) {
'Windows' {
# For x86 and x64 architectures, we use win7-x64 and win7-x86 RIDs.
# For arm and arm64 architectures, we use win-arm and win-arm64 RIDs.
$Platform = if ($Architecture[0] -eq 'x') { 'win7' } else { 'win' }
$Runtime = "${Platform}-${Architecture}"
}
} else {
$RID = dotnet --info | ForEach-Object {
if ($_ -match "RID") {
$_ -split "\s+" | Select-Object -Last 1
}

'Linux' {
$Runtime = "linux-${Architecture}"
}

# We plan to release packages targeting win7-x64 and win7-x86 RIDs,
# which supports all supported windows platforms.
# So we, will change the RID to win7-<arch>
$Runtime = $RID -replace "win\d+", "win7"
'Darwin' {
$Runtime = "osx-${Architecture}"
}
}

if (-not $Runtime) {
Expand Down Expand Up @@ -2272,7 +2276,7 @@ function Start-DevPowerShell {

# splatting for the win
$startProcessArgs = @{
FilePath = "$BinDir\pwsh"
FilePath = Join-Path $BinDir 'pwsh'
}

if ($ArgumentList) {
Expand Down