@@ -29,7 +29,9 @@ $script:dotnetTestArgs = @(
2929)
3030
3131$script :IsNix = $IsLinux -or $IsMacOS
32- $script :IsRosetta = $IsMacOS -and (sysctl - n sysctl.proc_translated) -eq 1 # Mac M1
32+ # For Apple M1, pwsh might be getting emulated, in which case we need to check
33+ # for the proc_translated flag, otherwise we can check the architecture.
34+ $script :IsAppleM1 = $IsMacOS -and ((sysctl - n sysctl.proc_translated) -eq 1 -or (uname - m) -eq " arm64" )
3335$script :BuildInfoPath = [System.IO.Path ]::Combine($PSScriptRoot , " src" , " PowerShellEditorServices.Hosting" , " BuildInfo.cs" )
3436$script :PsesCommonProps = [xml ](Get-Content - Raw " $PSScriptRoot /PowerShellEditorServices.Common.props" )
3537
@@ -110,8 +112,12 @@ task SetupDotNet -Before Clean, Build, TestServerWinPS, TestServerPS7, TestServe
110112
111113 if (! (Test-Path $dotnetExePath )) {
112114 # TODO: Test .NET 5 with PowerShell 7.1
115+ #
116+ # We use the .NET 6 SDK, so we always install it and its runtime.
113117 Install-Dotnet - Channel ' 6.0' # SDK and runtime
114- Install-Dotnet - Channel ' 3.1' , ' 5.0' - Runtime # Runtime only
118+ # Anywhere other than on a Mac with an M1 processor, we additionally
119+ # install the .NET 3.1 and 5.0 runtimes (but not their SDKs).
120+ if (! $script :IsAppleM1 ) { Install-Dotnet - Channel ' 3.1' , ' 5.0' - Runtime }
115121 }
116122
117123 # This variable is used internally by 'dotnet' to know where it's installed
@@ -235,7 +241,7 @@ task TestServerWinPS -If (-not $script:IsNix) {
235241 exec { & $script :dotnetExe $script :dotnetTestArgs $script :NetRuntime.Desktop }
236242}
237243
238- task TestServerPS7 - If (-not $script :IsRosetta ) {
244+ task TestServerPS7 - If (-not $script :IsAppleM1 ) {
239245 Set-Location .\test\PowerShellEditorServices.Test\
240246 exec { & $script :dotnetExe $script :dotnetTestArgs $script :NetRuntime.PS7 }
241247}
@@ -249,7 +255,7 @@ task TestE2E {
249255 Set-Location .\test\PowerShellEditorServices.Test.E2E\
250256
251257 $env: PWSH_EXE_NAME = if ($IsCoreCLR ) { " pwsh" } else { " powershell" }
252- $NetRuntime = if ($IsRosetta ) { $script :NetRuntime.PS72 } else { $script :NetRuntime.PS7 }
258+ $NetRuntime = if ($IsAppleM1 ) { $script :NetRuntime.PS72 } else { $script :NetRuntime.PS7 }
253259 exec { & $script :dotnetExe $script :dotnetTestArgs $NetRuntime }
254260
255261 # Run E2E tests in ConstrainedLanguage mode.
0 commit comments