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

Fix build for Apple M1 when running PowerShell 7.2 (arm64) #1628

Merged
merged 2 commits into from
Nov 10, 2021
Merged
Show file tree
Hide file tree
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
14 changes: 10 additions & 4 deletions PowerShellEditorServices.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 }
}
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
<ProjectReference Include="..\PowerShellEditorServices.Test.Shared\PowerShellEditorServices.Test.Shared.csproj" />
</ItemGroup>

<!-- This is for testing PowerShell 7.2 LTS -->
<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.2.0-preview.3" />
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.2.0" />
</ItemGroup>

<!-- This is for testing PowerShell 7.0 LTS -->
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.0.6" />
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.0.8" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
Expand Down