18
18
19
19
# Requires -Modules @ {ModuleName = " InvokeBuild" ;ModuleVersion = " 3.2.1" }
20
20
21
- $script :IsUnix = $PSVersionTable.PSEdition -and $PSVersionTable.PSEdition -eq " Core" -and ! $IsWindows
21
+ $script :IsNix = $IsLinux -or $IsMacOS
22
+ $script :IsRosetta = $IsMacOS -and (sysctl - n sysctl.proc_translated) -eq 1 # Mac M1
22
23
$script :BuildInfoPath = [System.IO.Path ]::Combine($PSScriptRoot , " src" , " PowerShellEditorServices.Hosting" , " BuildInfo.cs" )
23
24
$script :PsesCommonProps = [xml ](Get-Content - Raw " $PSScriptRoot /PowerShellEditorServices.Common.props" )
24
25
$script :IsPreview = [bool ]($script :PsesCommonProps.Project.PropertyGroup.VersionSuffix )
@@ -62,7 +63,7 @@ function Install-Dotnet {
62
63
Write-Host " Installing .NET channels $Channel " - ForegroundColor Green
63
64
64
65
# The install script is platform-specific
65
- $installScriptExt = if ($script :IsUnix ) { " sh" } else { " ps1" }
66
+ $installScriptExt = if ($script :IsNix ) { " sh" } else { " ps1" }
66
67
$installScript = " dotnet-install.$installScriptExt "
67
68
68
69
# Download the official installation script and run it
@@ -74,11 +75,11 @@ function Install-Dotnet {
74
75
{
75
76
Write-Host " `n ### Installing .NET CLI $Version ...`n "
76
77
77
- if ($script :IsUnix ) {
78
+ if ($script :IsNix ) {
78
79
chmod + x $installScriptPath
79
80
}
80
81
81
- $params = if ($script :IsUnix )
82
+ $params = if ($script :IsNix )
82
83
{
83
84
@ (' -Channel' , $dotnetChannel , ' -InstallDir' , $env: DOTNET_INSTALL_DIR , ' -NoPath' , ' -Verbose' )
84
85
}
@@ -105,7 +106,7 @@ function Install-Dotnet {
105
106
task SetupDotNet - Before Clean , Build, TestServerWinPS, TestServerPS7, TestServerPS72, TestE2E {
106
107
107
108
$dotnetPath = " $PSScriptRoot /.dotnet"
108
- $dotnetExePath = if ($script :IsUnix ) { " $dotnetPath /dotnet" } else { " $dotnetPath /dotnet.exe" }
109
+ $dotnetExePath = if ($script :IsNix ) { " $dotnetPath /dotnet" } else { " $dotnetPath /dotnet.exe" }
109
110
110
111
if (! (Test-Path $dotnetExePath )) {
111
112
# TODO: Test .NET 5 with PowerShell 7.1, and add that channel here.
@@ -238,7 +239,7 @@ task SetupHelpForTests {
238
239
task Build BinClean, {
239
240
exec { & $script :dotnetExe publish - c $Configuration .\src\PowerShellEditorServices\PowerShellEditorServices.csproj -f $script :NetRuntime.Standard }
240
241
exec { & $script :dotnetExe publish - c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script :NetRuntime.PS7 }
241
- if (-not $script :IsUnix )
242
+ if (-not $script :IsNix )
242
243
{
243
244
exec { & $script :dotnetExe publish - c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script :NetRuntime.Desktop }
244
245
}
@@ -256,12 +257,12 @@ task Test SetupHelpForTests,TestServer,TestE2E
256
257
257
258
task TestServer TestServerWinPS, TestServerPS7, TestServerPS72
258
259
259
- task TestServerWinPS - If (-not $script :IsUnix ) {
260
+ task TestServerWinPS - If (-not $script :IsNix ) {
260
261
Set-Location .\test\PowerShellEditorServices.Test\
261
262
exec { & $script :dotnetExe test -- logger trx -f $script :NetRuntime.Desktop (DotNetTestFilter) }
262
263
}
263
264
264
- task TestServerPS7 {
265
+ task TestServerPS7 - If ( -not $ script :IsRosetta ) {
265
266
Set-Location .\test\PowerShellEditorServices.Test\
266
267
Invoke-WithCreateDefaultHook - NewModulePath $script :PSCoreModulePath {
267
268
exec { & $script :dotnetExe test -- logger trx -f $script :NetRuntime.PS7 (DotNetTestFilter) }
@@ -279,10 +280,11 @@ task TestE2E {
279
280
Set-Location .\test\PowerShellEditorServices.Test.E2E\
280
281
281
282
$env: PWSH_EXE_NAME = if ($IsCoreCLR ) { " pwsh" } else { " powershell" }
282
- exec { & $script :dotnetExe test -- logger trx -f $script :NetRuntime.PS7 (DotNetTestFilter) }
283
+ $NetRuntime = if ($IsRosetta ) { $script :NetRuntime.PS72 } else { $script :NetRuntime.PS7 }
284
+ exec { & $script :dotnetExe test -- logger trx -f $NetRuntime (DotNetTestFilter) }
283
285
284
286
# Run E2E tests in ConstrainedLanguage mode.
285
- if (! $script :IsUnix ) {
287
+ if (! $script :IsNix ) {
286
288
try {
287
289
[System.Environment ]::SetEnvironmentVariable(" __PSLockdownPolicy" , " 0x80000007" , [System.EnvironmentVariableTarget ]::Machine);
288
290
exec { & $script :dotnetExe test -- logger trx -f $script :NetRuntime.PS7 (DotNetTestFilter) }
@@ -340,7 +342,7 @@ task LayoutModule -After Build {
340
342
}
341
343
342
344
# PSES/bin/Desktop
343
- if (-not $script :IsUnix )
345
+ if (-not $script :IsNix )
344
346
{
345
347
foreach ($hostComponent in Get-ChildItem $script :HostDeskOutput )
346
348
{
0 commit comments