diff --git a/PowerShellEditorServices.build.ps1 b/PowerShellEditorServices.build.ps1 index 9e98a1445..d2a2169d1 100644 --- a/PowerShellEditorServices.build.ps1 +++ b/PowerShellEditorServices.build.ps1 @@ -29,7 +29,9 @@ $script:dotnetTestArgs = @( ) $script:IsNix = $IsLinux -or $IsMacOS -$script:IsRosetta = $IsMacOS -and (sysctl -n sysctl.proc_translated) -eq 1 # Mac M1 +# For Apple M1, pwsh might be getting emulated, in which case we need to check +# for the proc_translated flag, otherwise we can check the architecture. +$script:IsAppleM1 = $IsMacOS -and ((sysctl -n sysctl.proc_translated) -eq 1 -or (uname -m) -eq "arm64") $script:BuildInfoPath = [System.IO.Path]::Combine($PSScriptRoot, "src", "PowerShellEditorServices.Hosting", "BuildInfo.cs") $script:PsesCommonProps = [xml](Get-Content -Raw "$PSScriptRoot/PowerShellEditorServices.Common.props") @@ -110,8 +112,12 @@ task SetupDotNet -Before Clean, Build, TestServerWinPS, TestServerPS7, TestServe if (!(Test-Path $dotnetExePath)) { # TODO: Test .NET 5 with PowerShell 7.1 + # + # We use the .NET 6 SDK, so we always install it and its runtime. Install-Dotnet -Channel '6.0' # SDK and runtime - Install-Dotnet -Channel '3.1','5.0' -Runtime # Runtime only + # Anywhere other than on a Mac with an M1 processor, we additionally + # install the .NET 3.1 and 5.0 runtimes (but not their SDKs). + if (!$script:IsAppleM1) { Install-Dotnet -Channel '3.1','5.0' -Runtime } } # This variable is used internally by 'dotnet' to know where it's installed @@ -235,7 +241,7 @@ task TestServerWinPS -If (-not $script:IsNix) { exec { & $script:dotnetExe $script:dotnetTestArgs $script:NetRuntime.Desktop } } -task TestServerPS7 -If (-not $script:IsRosetta) { +task TestServerPS7 -If (-not $script:IsAppleM1) { Set-Location .\test\PowerShellEditorServices.Test\ exec { & $script:dotnetExe $script:dotnetTestArgs $script:NetRuntime.PS7 } } @@ -249,7 +255,7 @@ task TestE2E { Set-Location .\test\PowerShellEditorServices.Test.E2E\ $env:PWSH_EXE_NAME = if ($IsCoreCLR) { "pwsh" } else { "powershell" } - $NetRuntime = if ($IsRosetta) { $script:NetRuntime.PS72 } else { $script:NetRuntime.PS7 } + $NetRuntime = if ($IsAppleM1) { $script:NetRuntime.PS72 } else { $script:NetRuntime.PS7 } exec { & $script:dotnetExe $script:dotnetTestArgs $NetRuntime } # Run E2E tests in ConstrainedLanguage mode. diff --git a/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj b/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj index fce802137..956dc796e 100644 --- a/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj +++ b/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj @@ -17,12 +17,14 @@ + - + + - +