@@ -19,18 +19,19 @@ param(
1919# Requires -Modules @ {ModuleName = " InvokeBuild" ;ModuleVersion = " 3.2.1" }
2020
2121$script :IsUnix = $PSVersionTable.PSEdition -and $PSVersionTable.PSEdition -eq " Core" -and ! $IsWindows
22- $script :RequiredSdkVersion = (Get-Content (Join-Path $PSScriptRoot ' global.json' ) | ConvertFrom-Json ).sdk.version
2322$script :BuildInfoPath = [System.IO.Path ]::Combine($PSScriptRoot , " src" , " PowerShellEditorServices.Hosting" , " BuildInfo.cs" )
2423$script :PsesCommonProps = [xml ](Get-Content - Raw " $PSScriptRoot /PowerShellEditorServices.Common.props" )
2524$script :IsPreview = [bool ]($script :PsesCommonProps.Project.PropertyGroup.VersionSuffix )
2625
2726$script :NetRuntime = @ {
28- Core = ' netcoreapp2.1'
27+ PS62 = ' netcoreapp2.1'
28+ PS7 = ' netcoreapp3.1'
29+ PS71 = ' net5.0'
2930 Desktop = ' net461'
3031 Standard = ' netstandard2.0'
3132}
3233
33- $script :HostCoreOutput = " $PSScriptRoot /src/PowerShellEditorServices.Hosting/bin/$Configuration /$ ( $script :NetRuntime.Core ) /publish"
34+ $script :HostCoreOutput = " $PSScriptRoot /src/PowerShellEditorServices.Hosting/bin/$Configuration /$ ( $script :NetRuntime.PS62 ) /publish"
3435$script :HostDeskOutput = " $PSScriptRoot /src/PowerShellEditorServices.Hosting/bin/$Configuration /$ ( $script :NetRuntime.Desktop ) /publish"
3536$script :PsesOutput = " $PSScriptRoot /src/PowerShellEditorServices/bin/$Configuration /$ ( $script :NetRuntime.Standard ) /publish"
3637$script :VSCodeOutput = " $PSScriptRoot /src/PowerShellEditorServices.VSCode/bin/$Configuration /$ ( $script :NetRuntime.Standard ) /publish"
@@ -52,64 +53,45 @@ function Invoke-WithCreateDefaultHook {
5253 }
5354}
5455
55- task SetupDotNet - Before Clean , Build, TestHost, TestServer, TestE2E {
56+ function Install-Dotnet {
57+ param (
58+ $Channel
59+ )
5660
57- $dotnetPath = " $PSScriptRoot /.dotnet"
58- $dotnetExePath = if ($script :IsUnix ) { " $dotnetPath /dotnet" } else { " $dotnetPath /dotnet.exe" }
59- $originalDotNetExePath = $dotnetExePath
61+ Write-Host " `n ### Installing .NET CLI $Version ...`n " - ForegroundColor Green
6062
61- if (! (Test-Path $dotnetExePath )) {
62- $installedDotnet = Get-Command dotnet - ErrorAction Ignore
63- if ($installedDotnet ) {
64- $dotnetExePath = $installedDotnet.Source
65- }
66- else {
67- $dotnetExePath = $null
68- }
69- }
63+ # The install script is platform-specific
64+ $installScriptExt = if ($script :IsUnix ) { " sh" } else { " ps1" }
7065
71- # Make sure the dotnet we found is the right version
72- if ($dotnetExePath ) {
73- # dotnet --version can write to stderr, which causes builds to abort, therefore use --list-sdks instead.
74- if ((& $dotnetExePath -- list- sdks | ForEach-Object { $_.Split ()[0 ] } ) -contains $script :RequiredSdkVersion ) {
75- $script :dotnetExe = $dotnetExePath
76- }
77- else {
78- # Clear the path so that we invoke installation
79- $script :dotnetExe = $null
80- }
81- }
82- else {
83- # Clear the path so that we invoke installation
84- $script :dotnetExe = $null
85- }
66+ # Download the official installation script and run it
67+ $installScriptPath = " $ ( [System.IO.Path ]::GetTempPath()) dotnet-install.$installScriptExt "
68+ Invoke-WebRequest " https://dot.net/v1/dotnet-install.$installScriptExt " - OutFile $installScriptPath
69+ $env: DOTNET_INSTALL_DIR = " $PSScriptRoot /.dotnet"
8670
87- if ($script :dotnetExe -eq $null ) {
71+ if ($script :IsUnix ) {
72+ chmod + x $installScriptPath
73+ }
8874
89- Write-Host " `n ### Installing .NET CLI $script :RequiredSdkVersion ...`n " - ForegroundColor Green
75+ $paramArr = @ (' -Channel' , $Channel , ' -InstallDir' , " '$env: DOTNET_INSTALL_DIR '" , ' -NoPath' )
76+ Invoke-Expression " $installScriptPath $paramArr "
77+ $env: PATH = $env: DOTNET_INSTALL_DIR + [System.IO.Path ]::PathSeparator + $env: PATH
9078
91- # The install script is platform-specific
92- $installScriptExt = if ( $ script :IsUnix ) { " sh " } else { " ps1 " }
79+ Write-Host " `n ### Installation complete. " - ForegroundColor Green
80+ }
9381
94- # Download the official installation script and run it
95- $installScriptPath = " $ ( [System.IO.Path ]::GetTempPath()) dotnet-install.$installScriptExt "
96- Invoke-WebRequest " https://raw.githubusercontent.com/dotnet/sdk/master/scripts/obtain/dotnet-install.$installScriptExt " - OutFile $installScriptPath
97- $env: DOTNET_INSTALL_DIR = " $PSScriptRoot /.dotnet"
82+ task SetupDotNet - Before Clean , Build, TestHost, TestServerWinPS, TestServerPS7, TestServerPS71, TestE2E {
9883
99- if (! $script :IsUnix ) {
100- & $installScriptPath - Version $script :RequiredSdkVersion - InstallDir " $env: DOTNET_INSTALL_DIR "
101- }
102- else {
103- & / bin/ bash $installScriptPath - Version $script :RequiredSdkVersion - InstallDir " $env: DOTNET_INSTALL_DIR "
104- $env: PATH = $dotnetExeDir + [System.IO.Path ]::PathSeparator + $env: PATH
105- }
84+ $dotnetPath = " $PSScriptRoot /.dotnet"
85+ $dotnetExePath = if ($script :IsUnix ) { " $dotnetPath /dotnet" } else { " $dotnetPath /dotnet.exe" }
10686
107- Write-Host " `n ### Installation complete." - ForegroundColor Green
108- $script :dotnetExe = $originalDotnetExePath
87+ if (! (Test-Path $dotnetExePath )) {
88+ Install-Dotnet - Channel ' 2.1'
89+ Install-Dotnet - Channel ' 3.1'
90+ Install-Dotnet - Channel ' release/5.0.1xx-preview6'
10991 }
11092
11193 # This variable is used internally by 'dotnet' to know where it's installed
112- $script :dotnetExe = Resolve-Path $script :dotnetExe
94+ $script :dotnetExe = Resolve-Path $dotnetExePath
11395 if (! $env: DOTNET_INSTALL_DIR )
11496 {
11597 $dotnetExeDir = [System.IO.Path ]::GetDirectoryName($script :dotnetExe )
@@ -228,7 +210,7 @@ task SetupHelpForTests -Before Test {
228210
229211task Build BinClean, {
230212 exec { & $script :dotnetExe publish - c $Configuration .\src\PowerShellEditorServices\PowerShellEditorServices.csproj -f $script :NetRuntime.Standard }
231- exec { & $script :dotnetExe publish - c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script :NetRuntime.Core }
213+ exec { & $script :dotnetExe publish - c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script :NetRuntime.PS62 }
232214 if (-not $script :IsUnix )
233215 {
234216 exec { & $script :dotnetExe publish - c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script :NetRuntime.Desktop }
@@ -245,15 +227,24 @@ function DotNetTestFilter {
245227
246228task Test TestServer, TestE2E
247229
248- task TestServer {
230+ task TestServer TestServerWinPS, TestServerPS7, TestServerPS71
231+
232+ task TestServerWinPS - If (-not $script :IsUnix ) {
249233 Set-Location .\test\PowerShellEditorServices.Test\
234+ exec { & $script :dotnetExe test -- logger trx -f $script :NetRuntime.Desktop (DotNetTestFilter) }
235+ }
250236
251- if (-not $script :IsUnix ) {
252- exec { & $script :dotnetExe test -- logger trx -f $script :NetRuntime.Desktop (DotNetTestFilter) }
237+ task TestServerPS7 {
238+ Set-Location .\test\PowerShellEditorServices.Test\
239+ Invoke-WithCreateDefaultHook - NewModulePath $script :PSCoreModulePath {
240+ exec { & $script :dotnetExe test -- logger trx -f $script :NetRuntime.PS7 (DotNetTestFilter) }
253241 }
242+ }
254243
244+ task TestServerPS71 {
245+ Set-Location .\test\PowerShellEditorServices.Test\
255246 Invoke-WithCreateDefaultHook - NewModulePath $script :PSCoreModulePath {
256- exec { & $script :dotnetExe test -- logger trx -f $script :NetRuntime.Core (DotNetTestFilter) }
247+ exec { & $script :dotnetExe test -- logger trx -f $script :NetRuntime.PS71 (DotNetTestFilter) }
257248 }
258249}
259250
@@ -265,21 +256,21 @@ task TestHost {
265256 exec { & $script :dotnetExe test -f $script :NetRuntime.Desktop (DotNetTestFilter) }
266257 }
267258
268- exec { & $script :dotnetExe build - c $Configuration -f $script :NetRuntime.Core }
269- exec { & $script :dotnetExe test -f $script :NetRuntime.Core (DotNetTestFilter) }
259+ exec { & $script :dotnetExe build - c $Configuration -f $script :NetRuntime.PS62 }
260+ exec { & $script :dotnetExe test -f $script :NetRuntime.PS62 (DotNetTestFilter) }
270261}
271262
272263task TestE2E {
273264 Set-Location .\test\PowerShellEditorServices.Test.E2E\
274265
275266 $env: PWSH_EXE_NAME = if ($IsCoreCLR ) { " pwsh" } else { " powershell" }
276- exec { & $script :dotnetExe test -- logger trx -f $script :NetRuntime.Core (DotNetTestFilter) }
267+ exec { & $script :dotnetExe test -- logger trx -f $script :NetRuntime.PS62 (DotNetTestFilter) }
277268
278269 # Run E2E tests in ConstrainedLanguage mode.
279270 if (! $script :IsUnix ) {
280271 try {
281272 [System.Environment ]::SetEnvironmentVariable(" __PSLockdownPolicy" , " 0x80000007" , [System.EnvironmentVariableTarget ]::Machine);
282- exec { & $script :dotnetExe test -- logger trx -f $script :NetRuntime.Core (DotNetTestFilter) }
273+ exec { & $script :dotnetExe test -- logger trx -f $script :NetRuntime.PS62 (DotNetTestFilter) }
283274 } finally {
284275 [System.Environment ]::SetEnvironmentVariable(" __PSLockdownPolicy" , $null , [System.EnvironmentVariableTarget ]::Machine);
285276 }
@@ -303,10 +294,6 @@ task LayoutModule -After Build {
303294 # Copy Third Party Notices.txt to module folder
304295 Copy-Item - Force - Path " $PSScriptRoot \Third Party Notices.txt" - Destination $psesOutputPath
305296
306- # Copy UnixConsoleEcho native libraries
307- Copy-Item - Path " $script :PsesOutput /runtimes/osx-64/native/*" - Destination $psesDepsPath - Force
308- Copy-Item - Path " $script :PsesOutput /runtimes/linux-64/native/*" - Destination $psesDepsPath - Force
309-
310297 # Assemble PSES module
311298
312299 $includedDlls = [System.Collections.Generic.HashSet [string ]]::new()
0 commit comments