@@ -18,20 +18,20 @@ param(
1818
1919# Requires -Modules @ {ModuleName = " InvokeBuild" ;ModuleVersion = " 3.2.1" }
2020
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
2223$script :BuildInfoPath = [System.IO.Path ]::Combine($PSScriptRoot , " src" , " PowerShellEditorServices.Hosting" , " BuildInfo.cs" )
2324$script :PsesCommonProps = [xml ](Get-Content - Raw " $PSScriptRoot /PowerShellEditorServices.Common.props" )
2425$script :IsPreview = [bool ]($script :PsesCommonProps.Project.PropertyGroup.VersionSuffix )
2526
2627$script :NetRuntime = @ {
27- PS62 = ' netcoreapp2.1'
2828 PS7 = ' netcoreapp3.1'
29- PS71 = ' net5 .0'
29+ PS72 = ' net6 .0'
3030 Desktop = ' net461'
3131 Standard = ' netstandard2.0'
3232}
3333
34- $script :HostCoreOutput = " $PSScriptRoot /src/PowerShellEditorServices.Hosting/bin/$Configuration /$ ( $script :NetRuntime.PS62 ) /publish"
34+ $script :HostCoreOutput = " $PSScriptRoot /src/PowerShellEditorServices.Hosting/bin/$Configuration /$ ( $script :NetRuntime.PS7 ) /publish"
3535$script :HostDeskOutput = " $PSScriptRoot /src/PowerShellEditorServices.Hosting/bin/$Configuration /$ ( $script :NetRuntime.Desktop ) /publish"
3636$script :PsesOutput = " $PSScriptRoot /src/PowerShellEditorServices/bin/$Configuration /$ ( $script :NetRuntime.Standard ) /publish"
3737$script :VSCodeOutput = " $PSScriptRoot /src/PowerShellEditorServices.VSCode/bin/$Configuration /$ ( $script :NetRuntime.Standard ) /publish"
@@ -63,7 +63,7 @@ function Install-Dotnet {
6363 Write-Host " Installing .NET channels $Channel " - ForegroundColor Green
6464
6565 # The install script is platform-specific
66- $installScriptExt = if ($script :IsUnix ) { " sh" } else { " ps1" }
66+ $installScriptExt = if ($script :IsNix ) { " sh" } else { " ps1" }
6767 $installScript = " dotnet-install.$installScriptExt "
6868
6969 # Download the official installation script and run it
@@ -75,11 +75,11 @@ function Install-Dotnet {
7575 {
7676 Write-Host " `n ### Installing .NET CLI $Version ...`n "
7777
78- if ($script :IsUnix ) {
78+ if ($script :IsNix ) {
7979 chmod + x $installScriptPath
8080 }
8181
82- $params = if ($script :IsUnix )
82+ $params = if ($script :IsNix )
8383 {
8484 @ (' -Channel' , $dotnetChannel , ' -InstallDir' , $env: DOTNET_INSTALL_DIR , ' -NoPath' , ' -Verbose' )
8585 }
@@ -103,13 +103,14 @@ function Install-Dotnet {
103103 Write-Host ' .NET installation complete' - ForegroundColor Green
104104}
105105
106- task SetupDotNet - Before Clean , Build, TestHost , TestServerWinPS, TestServerPS7, TestServerPS71 , TestE2E {
106+ task SetupDotNet - Before Clean , Build, TestServerWinPS, TestServerPS7, TestServerPS72 , TestE2E {
107107
108108 $dotnetPath = " $PSScriptRoot /.dotnet"
109- $dotnetExePath = if ($script :IsUnix ) { " $dotnetPath /dotnet" } else { " $dotnetPath /dotnet.exe" }
109+ $dotnetExePath = if ($script :IsNix ) { " $dotnetPath /dotnet" } else { " $dotnetPath /dotnet.exe" }
110110
111111 if (! (Test-Path $dotnetExePath )) {
112- Install-Dotnet - Channel ' 2.1' , ' 3.1' , ' release/5.0.1xx-preview6'
112+ # TODO: Test .NET 5 with PowerShell 7.1, and add that channel here.
113+ Install-Dotnet - Channel ' 3.1' , ' release/6.0.1xx-preview2'
113114 }
114115
115116 # This variable is used internally by 'dotnet' to know where it's installed
@@ -237,8 +238,8 @@ task SetupHelpForTests {
237238
238239task Build BinClean, {
239240 exec { & $script :dotnetExe publish - c $Configuration .\src\PowerShellEditorServices\PowerShellEditorServices.csproj -f $script :NetRuntime.Standard }
240- exec { & $script :dotnetExe publish - c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script :NetRuntime.PS62 }
241- if (-not $script :IsUnix )
241+ exec { & $script :dotnetExe publish - c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script :NetRuntime.PS7 }
242+ if (-not $script :IsNix )
242243 {
243244 exec { & $script :dotnetExe publish - c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script :NetRuntime.Desktop }
244245 }
@@ -254,50 +255,39 @@ function DotNetTestFilter {
254255
255256task Test SetupHelpForTests, TestServer, TestE2E
256257
257- task TestServer TestServerWinPS, TestServerPS7, TestServerPS71
258+ task TestServer TestServerWinPS, TestServerPS7, TestServerPS72
258259
259- task TestServerWinPS - If (-not $script :IsUnix ) {
260+ task TestServerWinPS - If (-not $script :IsNix ) {
260261 Set-Location .\test\PowerShellEditorServices.Test\
261262 exec { & $script :dotnetExe test -- logger trx -f $script :NetRuntime.Desktop (DotNetTestFilter) }
262263}
263264
264- task TestServerPS7 {
265+ task TestServerPS7 - If ( -not $ script :IsRosetta ) {
265266 Set-Location .\test\PowerShellEditorServices.Test\
266267 Invoke-WithCreateDefaultHook - NewModulePath $script :PSCoreModulePath {
267268 exec { & $script :dotnetExe test -- logger trx -f $script :NetRuntime.PS7 (DotNetTestFilter) }
268269 }
269270}
270271
271- task TestServerPS71 {
272+ task TestServerPS72 {
272273 Set-Location .\test\PowerShellEditorServices.Test\
273274 Invoke-WithCreateDefaultHook - NewModulePath $script :PSCoreModulePath {
274- exec { & $script :dotnetExe test -- logger trx -f $script :NetRuntime.PS71 (DotNetTestFilter) }
275+ exec { & $script :dotnetExe test -- logger trx -f $script :NetRuntime.PS72 (DotNetTestFilter) }
275276 }
276277}
277278
278- task TestHost {
279- Set-Location .\test\PowerShellEditorServices.Test.Host\
280-
281- if (-not $script :IsUnix ) {
282- exec { & $script :dotnetExe build -f $script :NetRuntime.Desktop }
283- exec { & $script :dotnetExe test -f $script :NetRuntime.Desktop (DotNetTestFilter) }
284- }
285-
286- exec { & $script :dotnetExe build - c $Configuration -f $script :NetRuntime.PS62 }
287- exec { & $script :dotnetExe test -f $script :NetRuntime.PS62 (DotNetTestFilter) }
288- }
289-
290279task TestE2E {
291280 Set-Location .\test\PowerShellEditorServices.Test.E2E\
292281
293282 $env: PWSH_EXE_NAME = if ($IsCoreCLR ) { " pwsh" } else { " powershell" }
294- exec { & $script :dotnetExe test -- logger trx -f $script :NetRuntime.PS62 (DotNetTestFilter) }
283+ $NetRuntime = if ($IsRosetta ) { $script :NetRuntime.PS72 } else { $script :NetRuntime.PS7 }
284+ exec { & $script :dotnetExe test -- logger trx -f $NetRuntime (DotNetTestFilter) }
295285
296286 # Run E2E tests in ConstrainedLanguage mode.
297- if (! $script :IsUnix ) {
287+ if (! $script :IsNix ) {
298288 try {
299289 [System.Environment ]::SetEnvironmentVariable(" __PSLockdownPolicy" , " 0x80000007" , [System.EnvironmentVariableTarget ]::Machine);
300- exec { & $script :dotnetExe test -- logger trx -f $script :NetRuntime.PS62 (DotNetTestFilter) }
290+ exec { & $script :dotnetExe test -- logger trx -f $script :NetRuntime.PS7 (DotNetTestFilter) }
301291 } finally {
302292 [System.Environment ]::SetEnvironmentVariable(" __PSLockdownPolicy" , $null , [System.EnvironmentVariableTarget ]::Machine);
303293 }
@@ -352,7 +342,7 @@ task LayoutModule -After Build {
352342 }
353343
354344 # PSES/bin/Desktop
355- if (-not $script :IsUnix )
345+ if (-not $script :IsNix )
356346 {
357347 foreach ($hostComponent in Get-ChildItem $script :HostDeskOutput )
358348 {
0 commit comments