@@ -18,20 +18,20 @@ param(
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 )
25
26
26
27
$script :NetRuntime = @ {
27
- PS62 = ' netcoreapp2.1'
28
28
PS7 = ' netcoreapp3.1'
29
- PS71 = ' net5 .0'
29
+ PS72 = ' net6 .0'
30
30
Desktop = ' net461'
31
31
Standard = ' netstandard2.0'
32
32
}
33
33
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"
35
35
$script :HostDeskOutput = " $PSScriptRoot /src/PowerShellEditorServices.Hosting/bin/$Configuration /$ ( $script :NetRuntime.Desktop ) /publish"
36
36
$script :PsesOutput = " $PSScriptRoot /src/PowerShellEditorServices/bin/$Configuration /$ ( $script :NetRuntime.Standard ) /publish"
37
37
$script :VSCodeOutput = " $PSScriptRoot /src/PowerShellEditorServices.VSCode/bin/$Configuration /$ ( $script :NetRuntime.Standard ) /publish"
@@ -63,7 +63,7 @@ function Install-Dotnet {
63
63
Write-Host " Installing .NET channels $Channel " - ForegroundColor Green
64
64
65
65
# The install script is platform-specific
66
- $installScriptExt = if ($script :IsUnix ) { " sh" } else { " ps1" }
66
+ $installScriptExt = if ($script :IsNix ) { " sh" } else { " ps1" }
67
67
$installScript = " dotnet-install.$installScriptExt "
68
68
69
69
# Download the official installation script and run it
@@ -75,11 +75,11 @@ function Install-Dotnet {
75
75
{
76
76
Write-Host " `n ### Installing .NET CLI $Version ...`n "
77
77
78
- if ($script :IsUnix ) {
78
+ if ($script :IsNix ) {
79
79
chmod + x $installScriptPath
80
80
}
81
81
82
- $params = if ($script :IsUnix )
82
+ $params = if ($script :IsNix )
83
83
{
84
84
@ (' -Channel' , $dotnetChannel , ' -InstallDir' , $env: DOTNET_INSTALL_DIR , ' -NoPath' , ' -Verbose' )
85
85
}
@@ -103,13 +103,14 @@ function Install-Dotnet {
103
103
Write-Host ' .NET installation complete' - ForegroundColor Green
104
104
}
105
105
106
- task SetupDotNet - Before Clean , Build, TestHost , TestServerWinPS, TestServerPS7, TestServerPS71 , TestE2E {
106
+ task SetupDotNet - Before Clean , Build, TestServerWinPS, TestServerPS7, TestServerPS72 , TestE2E {
107
107
108
108
$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" }
110
110
111
111
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'
113
114
}
114
115
115
116
# This variable is used internally by 'dotnet' to know where it's installed
@@ -237,8 +238,8 @@ task SetupHelpForTests {
237
238
238
239
task Build BinClean, {
239
240
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 )
242
243
{
243
244
exec { & $script :dotnetExe publish - c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script :NetRuntime.Desktop }
244
245
}
@@ -254,50 +255,39 @@ function DotNetTestFilter {
254
255
255
256
task Test SetupHelpForTests, TestServer, TestE2E
256
257
257
- task TestServer TestServerWinPS, TestServerPS7, TestServerPS71
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) }
268
269
}
269
270
}
270
271
271
- task TestServerPS71 {
272
+ task TestServerPS72 {
272
273
Set-Location .\test\PowerShellEditorServices.Test\
273
274
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) }
275
276
}
276
277
}
277
278
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
-
290
279
task TestE2E {
291
280
Set-Location .\test\PowerShellEditorServices.Test.E2E\
292
281
293
282
$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) }
295
285
296
286
# Run E2E tests in ConstrainedLanguage mode.
297
- if (! $script :IsUnix ) {
287
+ if (! $script :IsNix ) {
298
288
try {
299
289
[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) }
301
291
} finally {
302
292
[System.Environment ]::SetEnvironmentVariable(" __PSLockdownPolicy" , $null , [System.EnvironmentVariableTarget ]::Machine);
303
293
}
@@ -352,7 +342,7 @@ task LayoutModule -After Build {
352
342
}
353
343
354
344
# PSES/bin/Desktop
355
- if (-not $script :IsUnix )
345
+ if (-not $script :IsNix )
356
346
{
357
347
foreach ($hostComponent in Get-ChildItem $script :HostDeskOutput )
358
348
{
0 commit comments