19
19
[string []]$TestArgs = @ (" --logger" , " trx" )
20
20
)
21
21
22
- # Requires -Modules @ {ModuleName = " InvokeBuild" ;ModuleVersion = " 3.2.1" }
22
+ # Requires -Modules @ {ModuleName = " InvokeBuild" ; ModuleVersion = " 5.0.0" }
23
+ # Requires -Modules @ {ModuleName = " platyPS" ; ModuleVersion = " 0.14.0" }
23
24
24
25
$script :dotnetTestArgs = @ (
25
26
" test"
@@ -52,84 +53,18 @@ if (Get-Command git -ErrorAction SilentlyContinue) {
52
53
git update-index -- assume- unchanged " $PSScriptRoot /src/PowerShellEditorServices.Hosting/BuildInfo.cs"
53
54
}
54
55
55
- function Install-Dotnet {
56
- param (
57
- [string []]$Channel ,
58
- [switch ]$Runtime
59
- )
56
+ task FindDotNet {
57
+ assert (Get-Command dotnet - ErrorAction SilentlyContinue) " dotnet not found, please install it: https://aka.ms/dotnet-cli"
58
+ assert ([Version ](dotnet -- version) -ge [Version ](" 6.0" )) " .NET SDK 6.0 or higher is required, please update it: https://aka.ms/dotnet-cli"
60
59
61
- $env: DOTNET_INSTALL_DIR = " $PSScriptRoot /.dotnet"
62
-
63
- $components = if ($Runtime ) { " Runtime " } else { " SDK and Runtime " }
64
- $components += $Channel -join ' , '
65
-
66
- Write-Host " Installing .NET $components " - ForegroundColor Green
67
-
68
- # The install script is platform-specific
69
- $installScriptExt = if ($script :IsNix ) { " sh" } else { " ps1" }
70
- $installScript = " dotnet-install.$installScriptExt "
71
-
72
- # Download the official installation script and run it
73
- $installScriptPath = Join-Path ([System.IO.Path ]::GetTempPath()) $installScript
74
- Invoke-WebRequest " https://dot.net/v1/$installScript " - OutFile $installScriptPath
75
-
76
- # Download and install the different .NET channels
77
- foreach ($dotnetChannel in $Channel )
78
- {
79
- if ($script :IsNix ) {
80
- chmod + x $installScriptPath
81
- }
82
-
83
- $params = if ($script :IsNix ) {
84
- @ (' -Channel' , $dotnetChannel , ' -InstallDir' , $env: DOTNET_INSTALL_DIR , ' -NoPath' , ' -Verbose' )
85
- } else {
86
- @ {
87
- Channel = $dotnetChannel
88
- InstallDir = $env: DOTNET_INSTALL_DIR
89
- NoPath = $true
90
- Verbose = $true
91
- }
92
- }
93
-
94
- # Install just the runtime, not the SDK
95
- if ($Runtime ) {
96
- if ($script :IsNix ) { $params += @ (' -Runtime' , ' dotnet' ) }
97
- else { $params [' Runtime' ] = ' dotnet' }
98
- }
99
-
100
- exec { & $installScriptPath @params }
60
+ # Anywhere other than on a Mac with an M1 processor, we additionally
61
+ # need the .NET 3.1 runtime for our netcoreapp3.1 framework.
62
+ if (! $script :IsAppleM1 ) {
63
+ $runtimes = dotnet -- list- runtimes
64
+ assert ($runtimes -match " Microsoft.NETCore.App 3.1" ) " .NET Runtime 3.1 required but not found!"
101
65
}
102
66
103
- $env: PATH = $env: DOTNET_INSTALL_DIR + [System.IO.Path ]::PathSeparator + $env: PATH
104
-
105
- Write-Host ' .NET installation complete' - ForegroundColor Green
106
- }
107
-
108
- task SetupDotNet - Before Clean , Build, TestServerWinPS, TestServerPS7, TestServerPS72, TestE2E {
109
-
110
- $dotnetPath = " $PSScriptRoot /.dotnet"
111
- $dotnetExePath = if ($script :IsNix ) { " $dotnetPath /dotnet" } else { " $dotnetPath /dotnet.exe" }
112
-
113
- if (! (Test-Path $dotnetExePath )) {
114
- # TODO: Test .NET 5 with PowerShell 7.1
115
- #
116
- # We use the .NET 6 SDK, so we always install it and its runtime.
117
- Install-Dotnet - Channel ' 6.0' # SDK and runtime
118
- # Anywhere other than on a Mac with an M1 processor, we additionally
119
- # install the .NET 3.1 and 5.0 runtimes (but not their SDKs).
120
- if (! $script :IsAppleM1 ) { Install-Dotnet - Channel ' 3.1' , ' 5.0' - Runtime }
121
- }
122
-
123
- # This variable is used internally by 'dotnet' to know where it's installed
124
- $script :dotnetExe = Resolve-Path $dotnetExePath
125
- if (! $env: DOTNET_INSTALL_DIR )
126
- {
127
- $dotnetExeDir = [System.IO.Path ]::GetDirectoryName($script :dotnetExe )
128
- $env: PATH = $dotnetExeDir + [System.IO.Path ]::PathSeparator + $env: PATH
129
- $env: DOTNET_INSTALL_DIR = $dotnetExeDir
130
- }
131
-
132
- Write-Host " `n ### Using dotnet v$ ( & $script :dotnetExe -- version) at path $script :dotnetExe `n " - ForegroundColor Green
67
+ Write-Host " Using dotnet v$ ( dotnet -- version) at path $ ( (Get-Command dotnet).Source) " - ForegroundColor Green
133
68
}
134
69
135
70
task BinClean {
@@ -138,9 +73,8 @@ task BinClean {
138
73
Remove-Item $PSScriptRoot \module\PowerShellEditorServices.VSCode\bin - Recurse - Force - ErrorAction Ignore
139
74
}
140
75
141
- task Clean BinClean, {
142
- exec { & $script :dotnetExe restore }
143
- exec { & $script :dotnetExe clean }
76
+ task Clean FindDotNet, BinClean, {
77
+ exec { & dotnet clean }
144
78
Get-ChildItem - Recurse $PSScriptRoot \src\* .nupkg | Remove-Item - Force - ErrorAction Ignore
145
79
Get-ChildItem $PSScriptRoot \PowerShellEditorServices* .zip | Remove-Item - Force - ErrorAction Ignore
146
80
Get-ChildItem $PSScriptRoot \module\PowerShellEditorServices\Commands\en- US\*- help.xml | Remove-Item - Force - ErrorAction Ignore
@@ -155,7 +89,7 @@ task Clean BinClean,{
155
89
}
156
90
}
157
91
158
- task CreateBuildInfo - Before Build {
92
+ task CreateBuildInfo {
159
93
$buildVersion = " <development-build>"
160
94
$buildOrigin = " Development"
161
95
$buildCommit = git rev- parse HEAD
@@ -174,8 +108,7 @@ task CreateBuildInfo -Before Build {
174
108
$propsBody = $propsXml.Project.PropertyGroup
175
109
$buildVersion = $propsBody.VersionPrefix
176
110
177
- if ($propsBody.VersionSuffix )
178
- {
111
+ if ($propsBody.VersionSuffix ) {
179
112
$buildVersion += ' -' + $propsBody.VersionSuffix
180
113
}
181
114
}
@@ -217,59 +150,55 @@ task SetupHelpForTests {
217
150
Write-Host " Updating help for tests"
218
151
Update-Help - Module Microsoft.PowerShell.Utility - Force - Scope CurrentUser
219
152
}
220
- else
221
- {
222
- Write-Host " Write-Host help found -- Update-Help skipped"
223
- }
224
153
}
225
154
226
- Task Build {
227
- exec { & $ script :dotnetExe publish - c $Configuration .\src\PowerShellEditorServices\PowerShellEditorServices.csproj -f $ script :NetRuntime .Standard }
228
- exec { & $ script :dotnetExe publish - c $Configuration .\src\PowerShellEditorServices.Hosting \PowerShellEditorServices.Hosting. csproj -f $script :NetRuntime.PS7 }
229
- if ( -not $ script :IsNix )
230
- {
231
- exec { & $ script :dotnetExe publish - c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script :NetRuntime.Desktop }
155
+ Task Build FindDotNet , CreateBuildInfo , {
156
+ exec { & dotnet restore }
157
+ exec { & dotnet publish - c $Configuration .\src\PowerShellEditorServices\PowerShellEditorServices.csproj -f $script :NetRuntime.Standard }
158
+ exec { & dotnet publish - c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $ script :NetRuntime .PS7 }
159
+ if ( -not $ script :IsNix ) {
160
+ exec { & dotnet publish - c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script :NetRuntime.Desktop }
232
161
}
233
162
234
163
# Build PowerShellEditorServices.VSCode module
235
- exec { & $ script :dotnetExe publish - c $Configuration .\src\PowerShellEditorServices.VSCode\PowerShellEditorServices.VSCode.csproj -f $script :NetRuntime.Standard }
164
+ exec { & dotnet publish - c $Configuration .\src\PowerShellEditorServices.VSCode\PowerShellEditorServices.VSCode.csproj -f $script :NetRuntime.Standard }
236
165
}
237
166
238
- task Test SetupHelpForTests , TestServer, TestE2E
167
+ task Test TestServer, TestE2E
239
168
240
- task TestServer TestServerWinPS, TestServerPS7, TestServerPS72
169
+ task TestServer TestServerWinPS, TestServerPS7, TestServerPS72
241
170
242
- task TestServerWinPS - If (-not $script :IsNix ) {
171
+ Task TestServerWinPS - If (-not $script :IsNix ) Build , SetupHelpForTests , {
243
172
Set-Location .\test\PowerShellEditorServices.Test\
244
173
# TODO: See https://github.com/dotnet/sdk/issues/18353 for x64 test host
245
174
# that is debuggable! If architecture is added, the assembly path gets an
246
175
# additional folder, necesstiating fixes to find the commands definition
247
176
# file and test files.
248
- exec { & $ script :dotnetExe $script :dotnetTestArgs $script :NetRuntime.Desktop }
177
+ exec { & dotnet $script :dotnetTestArgs $script :NetRuntime.Desktop }
249
178
}
250
179
251
- task TestServerPS7 - If (-not $script :IsAppleM1 ) {
180
+ task TestServerPS7 - If (-not $script :IsAppleM1 ) Build , SetupHelpForTests , {
252
181
Set-Location .\test\PowerShellEditorServices.Test\
253
- exec { & $ script :dotnetExe $script :dotnetTestArgs $script :NetRuntime.PS7 }
182
+ exec { & dotnet $script :dotnetTestArgs $script :NetRuntime.PS7 }
254
183
}
255
184
256
- task TestServerPS72 {
185
+ task TestServerPS72 Build , SetupHelpForTests , {
257
186
Set-Location .\test\PowerShellEditorServices.Test\
258
- exec { & $ script :dotnetExe $script :dotnetTestArgs $script :NetRuntime.PS72 }
187
+ exec { & dotnet $script :dotnetTestArgs $script :NetRuntime.PS72 }
259
188
}
260
189
261
- task TestE2E {
190
+ task TestE2E Build , SetupHelpForTests , {
262
191
Set-Location .\test\PowerShellEditorServices.Test.E2E\
263
192
264
193
$env: PWSH_EXE_NAME = if ($IsCoreCLR ) { " pwsh" } else { " powershell" }
265
194
$NetRuntime = if ($IsAppleM1 ) { $script :NetRuntime.PS72 } else { $script :NetRuntime.PS7 }
266
- exec { & $ script :dotnetExe $script :dotnetTestArgs $NetRuntime }
195
+ exec { & dotnet $script :dotnetTestArgs $NetRuntime }
267
196
268
197
# Run E2E tests in ConstrainedLanguage mode.
269
198
if (! $script :IsNix ) {
270
199
try {
271
200
[System.Environment ]::SetEnvironmentVariable(" __PSLockdownPolicy" , " 0x80000007" , [System.EnvironmentVariableTarget ]::Machine);
272
- exec { & $ script :dotnetExe $script :dotnetTestArgs $script :NetRuntime.PS7 }
201
+ exec { & dotnet $script :dotnetTestArgs $script :NetRuntime.PS7 }
273
202
} finally {
274
203
[System.Environment ]::SetEnvironmentVariable(" __PSLockdownPolicy" , $null , [System.EnvironmentVariableTarget ]::Machine);
275
204
}
@@ -285,8 +214,7 @@ task LayoutModule -After Build {
285
214
$psesCoreHostPath = " $psesBinOutputPath /Core"
286
215
$psesDeskHostPath = " $psesBinOutputPath /Desktop"
287
216
288
- foreach ($dir in $psesDepsPath , $psesCoreHostPath , $psesDeskHostPath , $psesVSCodeBinOutputPath )
289
- {
217
+ foreach ($dir in $psesDepsPath , $psesCoreHostPath , $psesDeskHostPath , $psesVSCodeBinOutputPath ) {
290
218
New-Item - Force - Path $dir - ItemType Directory
291
219
}
292
220
@@ -299,56 +227,46 @@ task LayoutModule -After Build {
299
227
[void ]$includedDlls.Add (' System.Management.Automation.dll' )
300
228
301
229
# PSES/bin/Common
302
- foreach ($psesComponent in Get-ChildItem $script :PsesOutput )
303
- {
230
+ foreach ($psesComponent in Get-ChildItem $script :PsesOutput ) {
304
231
if ($psesComponent.Name -eq ' System.Management.Automation.dll' -or
305
- $psesComponent.Name -eq ' System.Runtime.InteropServices.RuntimeInformation.dll' )
306
- {
232
+ $psesComponent.Name -eq ' System.Runtime.InteropServices.RuntimeInformation.dll' ) {
307
233
continue
308
234
}
309
235
310
- if ($psesComponent.Extension )
311
- {
236
+ if ($psesComponent.Extension ) {
312
237
[void ]$includedDlls.Add ($psesComponent.Name )
313
238
Copy-Item - Path $psesComponent.FullName - Destination $psesDepsPath - Force
314
239
}
315
240
}
316
241
317
242
# PSES/bin/Core
318
- foreach ($hostComponent in Get-ChildItem $script :HostCoreOutput )
319
- {
320
- if (-not $includedDlls.Contains ($hostComponent.Name ))
321
- {
243
+ foreach ($hostComponent in Get-ChildItem $script :HostCoreOutput ) {
244
+ if (-not $includedDlls.Contains ($hostComponent.Name )) {
322
245
Copy-Item - Path $hostComponent.FullName - Destination $psesCoreHostPath - Force
323
246
}
324
247
}
325
248
326
249
# PSES/bin/Desktop
327
- if (-not $script :IsNix )
328
- {
329
- foreach ($hostComponent in Get-ChildItem $script :HostDeskOutput )
330
- {
331
- if (-not $includedDlls.Contains ($hostComponent.Name ))
332
- {
250
+ if (-not $script :IsNix ) {
251
+ foreach ($hostComponent in Get-ChildItem $script :HostDeskOutput ) {
252
+ if (-not $includedDlls.Contains ($hostComponent.Name )) {
333
253
Copy-Item - Path $hostComponent.FullName - Destination $psesDeskHostPath - Force
334
254
}
335
255
}
336
256
}
337
257
338
258
# Assemble the PowerShellEditorServices.VSCode module
339
259
340
- foreach ($vscodeComponent in Get-ChildItem $script :VSCodeOutput )
341
- {
342
- if (-not $includedDlls.Contains ($vscodeComponent.Name ))
343
- {
260
+ foreach ($vscodeComponent in Get-ChildItem $script :VSCodeOutput ) {
261
+ if (-not $includedDlls.Contains ($vscodeComponent.Name )) {
344
262
Copy-Item - Path $vscodeComponent.FullName - Destination $psesVSCodeBinOutputPath - Force
345
263
}
346
264
}
347
265
}
348
266
349
267
task RestorePsesModules - After Build {
350
268
$submodulePath = (Resolve-Path $PsesSubmodulePath ).Path + [IO.Path ]::DirectorySeparatorChar
351
- Write-Host " `n Restoring EditorServices modules..."
269
+ Write-Host " Restoring EditorServices modules..."
352
270
353
271
# Read in the modules.json file as a hashtable so it can be splatted
354
272
$moduleInfos = @ {}
@@ -398,14 +316,12 @@ task RestorePsesModules -After Build {
398
316
399
317
Save-Module @splatParameters
400
318
}
401
-
402
- Write-Host " `n "
403
319
}
404
320
405
- task BuildCmdletHelp {
321
+ Task BuildCmdletHelp - After LayoutModule {
406
322
New-ExternalHelp - Path $PSScriptRoot \module\docs - OutputPath $PSScriptRoot \module\PowerShellEditorServices\Commands\en- US - Force
407
323
New-ExternalHelp - Path $PSScriptRoot \module\PowerShellEditorServices.VSCode\docs - OutputPath $PSScriptRoot \module\PowerShellEditorServices.VSCode\en- US - Force
408
324
}
409
325
410
326
# The default task is to run the entire CI build
411
- task . Clean , Build, Test, BuildCmdletHelp
327
+ task . Clean , Build, Test
0 commit comments