@@ -19,18 +19,19 @@ param(
19
19
# Requires -Modules @ {ModuleName = " InvokeBuild" ;ModuleVersion = " 3.2.1" }
20
20
21
21
$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
23
22
$script :BuildInfoPath = [System.IO.Path ]::Combine($PSScriptRoot , " src" , " PowerShellEditorServices.Hosting" , " BuildInfo.cs" )
24
23
$script :PsesCommonProps = [xml ](Get-Content - Raw " $PSScriptRoot /PowerShellEditorServices.Common.props" )
25
24
$script :IsPreview = [bool ]($script :PsesCommonProps.Project.PropertyGroup.VersionSuffix )
26
25
27
26
$script :NetRuntime = @ {
28
- Core = ' netcoreapp2.1'
27
+ PS62 = ' netcoreapp2.1'
28
+ PS7 = ' netcoreapp3.1'
29
+ PS71 = ' net5.0'
29
30
Desktop = ' net461'
30
31
Standard = ' netstandard2.0'
31
32
}
32
33
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"
34
35
$script :HostDeskOutput = " $PSScriptRoot /src/PowerShellEditorServices.Hosting/bin/$Configuration /$ ( $script :NetRuntime.Desktop ) /publish"
35
36
$script :PsesOutput = " $PSScriptRoot /src/PowerShellEditorServices/bin/$Configuration /$ ( $script :NetRuntime.Standard ) /publish"
36
37
$script :VSCodeOutput = " $PSScriptRoot /src/PowerShellEditorServices.VSCode/bin/$Configuration /$ ( $script :NetRuntime.Standard ) /publish"
@@ -52,64 +53,45 @@ function Invoke-WithCreateDefaultHook {
52
53
}
53
54
}
54
55
55
- task SetupDotNet - Before Clean , Build, TestHost, TestServer, TestE2E {
56
+ function Install-Dotnet {
57
+ param (
58
+ $Channel
59
+ )
56
60
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
60
62
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" }
70
65
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"
86
70
87
- if ($script :dotnetExe -eq $null ) {
71
+ if ($script :IsUnix ) {
72
+ chmod + x $installScriptPath
73
+ }
88
74
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
90
78
91
- # The install script is platform-specific
92
- $installScriptExt = if ( $ script :IsUnix ) { " sh " } else { " ps1 " }
79
+ Write-Host " `n ### Installation complete. " - ForegroundColor Green
80
+ }
93
81
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 {
98
83
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" }
106
86
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'
109
91
}
110
92
111
93
# 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
113
95
if (! $env: DOTNET_INSTALL_DIR )
114
96
{
115
97
$dotnetExeDir = [System.IO.Path ]::GetDirectoryName($script :dotnetExe )
@@ -228,7 +210,7 @@ task SetupHelpForTests -Before Test {
228
210
229
211
task Build BinClean, {
230
212
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 }
232
214
if (-not $script :IsUnix )
233
215
{
234
216
exec { & $script :dotnetExe publish - c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script :NetRuntime.Desktop }
@@ -245,15 +227,24 @@ function DotNetTestFilter {
245
227
246
228
task Test TestServer, TestE2E
247
229
248
- task TestServer {
230
+ task TestServer TestServerWinPS, TestServerPS7, TestServerPS71
231
+
232
+ task TestServerWinPS - If (-not $script :IsUnix ) {
249
233
Set-Location .\test\PowerShellEditorServices.Test\
234
+ exec { & $script :dotnetExe test -- logger trx -f $script :NetRuntime.Desktop (DotNetTestFilter) }
235
+ }
250
236
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) }
253
241
}
242
+ }
254
243
244
+ task TestServerPS71 {
245
+ Set-Location .\test\PowerShellEditorServices.Test\
255
246
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) }
257
248
}
258
249
}
259
250
@@ -265,21 +256,21 @@ task TestHost {
265
256
exec { & $script :dotnetExe test -f $script :NetRuntime.Desktop (DotNetTestFilter) }
266
257
}
267
258
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) }
270
261
}
271
262
272
263
task TestE2E {
273
264
Set-Location .\test\PowerShellEditorServices.Test.E2E\
274
265
275
266
$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) }
277
268
278
269
# Run E2E tests in ConstrainedLanguage mode.
279
270
if (! $script :IsUnix ) {
280
271
try {
281
272
[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) }
283
274
} finally {
284
275
[System.Environment ]::SetEnvironmentVariable(" __PSLockdownPolicy" , $null , [System.EnvironmentVariableTarget ]::Machine);
285
276
}
@@ -303,10 +294,6 @@ task LayoutModule -After Build {
303
294
# Copy Third Party Notices.txt to module folder
304
295
Copy-Item - Force - Path " $PSScriptRoot \Third Party Notices.txt" - Destination $psesOutputPath
305
296
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
-
310
297
# Assemble PSES module
311
298
312
299
$includedDlls = [System.Collections.Generic.HashSet [string ]]::new()
0 commit comments