@@ -11,12 +11,13 @@ param(
11
11
12
12
[string ]$DefaultModuleRepository = " PSGallery" ,
13
13
14
+ [string []]$VerbosityArgs = @ (" --verbosity" , " quiet" , " --nologo" ),
15
+
14
16
# See: https://docs.microsoft.com/en-us/dotnet/core/testing/selective-unit-tests
15
17
[string ]$TestFilter = ' ' ,
16
18
17
19
# See: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-test
18
- # E.g. use @("--logger", "console;verbosity=detailed") for detailed console output instead
19
- [string []]$TestArgs = @ (" --logger" , " trx" )
20
+ [string []]$TestArgs = $VerbosityArgs + @ (" --logger" , " console;verbosity=normal" , " --logger" , " trx" )
20
21
)
21
22
22
23
# Requires -Modules @ {ModuleName = " InvokeBuild" ; ModuleVersion = " 5.0.0" }
@@ -38,9 +39,9 @@ $script:BuildInfoPath = [System.IO.Path]::Combine($PSScriptRoot, "src", "PowerSh
38
39
$script :PsesCommonProps = [xml ](Get-Content - Raw " $PSScriptRoot /PowerShellEditorServices.Common.props" )
39
40
40
41
$script :NetRuntime = @ {
41
- PS7 = ' netcoreapp3.1'
42
- PS72 = ' net6.0'
43
- Desktop = ' net462'
42
+ PS7 = ' netcoreapp3.1'
43
+ PS72 = ' net6.0'
44
+ Desktop = ' net462'
44
45
Standard = ' netstandard2.0'
45
46
}
46
47
@@ -54,31 +55,31 @@ if (Get-Command git -ErrorAction SilentlyContinue) {
54
55
git update-index -- assume- unchanged " $PSScriptRoot /src/PowerShellEditorServices.Hosting/BuildInfo.cs"
55
56
}
56
57
57
- task FindDotNet {
58
- assert (Get-Command dotnet - ErrorAction SilentlyContinue) " dotnet not found, please install it: https://aka.ms/dotnet-cli"
58
+ Task FindDotNet {
59
+ Assert (Get-Command dotnet - ErrorAction SilentlyContinue) " dotnet not found, please install it: https://aka.ms/dotnet-cli"
59
60
60
61
# Strip out semantic version metadata so it can be cast to `Version`
61
62
$existingVersion , $null = (dotnet -- version) -split ' -'
62
- assert ([Version ]$existingVersion -ge [Version ](" 6.0" )) " .NET SDK 6.0 or higher is required, please update it: https://aka.ms/dotnet-cli"
63
+ Assert ([Version ]$existingVersion -ge [Version ](" 6.0" )) " .NET SDK 6.0 or higher is required, please update it: https://aka.ms/dotnet-cli"
63
64
64
65
# Anywhere other than on a Mac with an M1 processor, we additionally
65
66
# need the .NET 3.1 runtime for our netcoreapp3.1 framework.
66
67
if (-not $script :IsAppleM1 -and -not $script :IsArm64 ) {
67
68
$runtimes = dotnet -- list- runtimes
68
- assert ($runtimes -match " Microsoft.NETCore.App 3.1" ) " .NET Runtime 3.1 required but not found!"
69
+ Assert ($runtimes -match " Microsoft.NETCore.App 3.1" ) " .NET Runtime 3.1 required but not found!"
69
70
}
70
71
71
72
Write-Host " Using dotnet v$ ( dotnet -- version) at path $ ( (Get-Command dotnet).Source) " - ForegroundColor Green
72
73
}
73
74
74
- task BinClean {
75
+ Task BinClean {
75
76
Remove-Item $PSScriptRoot \.tmp - Recurse - Force - ErrorAction Ignore
76
77
Remove-Item $PSScriptRoot \module\PowerShellEditorServices\bin - Recurse - Force - ErrorAction Ignore
77
78
Remove-Item $PSScriptRoot \module\PowerShellEditorServices.VSCode\bin - Recurse - Force - ErrorAction Ignore
78
79
}
79
80
80
- task Clean FindDotNet, BinClean, {
81
- exec { & dotnet clean }
81
+ Task Clean FindDotNet, BinClean, {
82
+ Exec { & dotnet clean $VerbosityArgs }
82
83
Get-ChildItem - Recurse $PSScriptRoot \src\* .nupkg | Remove-Item - Force - ErrorAction Ignore
83
84
Get-ChildItem $PSScriptRoot \PowerShellEditorServices* .zip | Remove-Item - Force - ErrorAction Ignore
84
85
Get-ChildItem $PSScriptRoot \module\PowerShellEditorServices\Commands\en- US\*- help.xml | Remove-Item - Force - ErrorAction Ignore
@@ -93,7 +94,7 @@ task Clean FindDotNet, BinClean, {
93
94
}
94
95
}
95
96
96
- task CreateBuildInfo {
97
+ Task CreateBuildInfo {
97
98
$buildVersion = " <development-build>"
98
99
$buildOrigin = " Development"
99
100
$buildCommit = git rev- parse HEAD
@@ -147,77 +148,77 @@ namespace Microsoft.PowerShell.EditorServices.Hosting
147
148
"@
148
149
149
150
if (Compare-Object $buildInfoContents.Split ([Environment ]::NewLine) (Get-Content $script :BuildInfoPath )) {
150
- Write-Host " Updating Build Info "
151
+ Write-Host " Updating build info. "
151
152
Set-Content - LiteralPath $script :BuildInfoPath - Value $buildInfoContents - Force
152
153
}
153
154
}
154
155
155
- task SetupHelpForTests {
156
+ Task SetupHelpForTests {
156
157
if (-not (Get-Help Write-Host ).Examples) {
157
- Write-Host " Updating help for tests"
158
+ Write-Host " Updating help for tests. "
158
159
Update-Help - Module Microsoft.PowerShell.Utility - Force - Scope CurrentUser
159
160
}
160
161
}
161
162
162
163
Task Build FindDotNet, CreateBuildInfo, {
163
- exec { & dotnet restore }
164
- exec { & dotnet publish - c $Configuration .\src\PowerShellEditorServices\PowerShellEditorServices.csproj -f $script :NetRuntime.Standard }
165
- exec { & dotnet publish - c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script :NetRuntime.PS7 }
164
+ Exec { & dotnet restore $VerbosityArgs }
165
+ Exec { & dotnet publish $VerbosityArgs - c $Configuration .\src\PowerShellEditorServices\PowerShellEditorServices.csproj -f $script :NetRuntime.Standard }
166
+ Exec { & dotnet publish $VerbosityArgs - c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script :NetRuntime.PS7 }
166
167
if (-not $script :IsNix ) {
167
- exec { & dotnet publish - c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script :NetRuntime.Desktop }
168
+ Exec { & dotnet publish $VerbosityArgs - c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script :NetRuntime.Desktop }
168
169
}
169
170
170
171
# Build PowerShellEditorServices.VSCode module
171
- exec { & dotnet publish - c $Configuration .\src\PowerShellEditorServices.VSCode\PowerShellEditorServices.VSCode.csproj -f $script :NetRuntime.Standard }
172
+ Exec { & dotnet publish $VerbosityArgs - c $Configuration .\src\PowerShellEditorServices.VSCode\PowerShellEditorServices.VSCode.csproj -f $script :NetRuntime.Standard }
172
173
}
173
174
174
- task Test TestServer, TestE2E
175
+ Task Test TestServer, TestE2E
175
176
176
- task TestServer TestServerWinPS, TestServerPS7, TestServerPS72
177
+ Task TestServer TestServerWinPS, TestServerPS7, TestServerPS72
177
178
178
179
Task TestServerWinPS - If (-not $script :IsNix ) Build, SetupHelpForTests, {
179
180
Set-Location .\test\PowerShellEditorServices.Test\
180
181
# TODO: See https://github.com/dotnet/sdk/issues/18353 for x64 test host
181
182
# that is debuggable! If architecture is added, the assembly path gets an
182
183
# additional folder, necesstiating fixes to find the commands definition
183
184
# file and test files.
184
- exec { & dotnet $script :dotnetTestArgs $script :NetRuntime.Desktop }
185
+ Exec { & dotnet $script :dotnetTestArgs $script :NetRuntime.Desktop }
185
186
}
186
187
187
- task TestServerPS7 - If (-not $script :IsAppleM1 -and -not $script :IsArm64 ) Build, SetupHelpForTests, {
188
+ Task TestServerPS7 - If (-not $script :IsAppleM1 -and -not $script :IsArm64 ) Build, SetupHelpForTests, {
188
189
Set-Location .\test\PowerShellEditorServices.Test\
189
- exec { & dotnet $script :dotnetTestArgs $script :NetRuntime.PS7 }
190
+ Exec { & dotnet $script :dotnetTestArgs $script :NetRuntime.PS7 }
190
191
}
191
192
192
- task TestServerPS72 Build, SetupHelpForTests, {
193
+ Task TestServerPS72 Build, SetupHelpForTests, {
193
194
Set-Location .\test\PowerShellEditorServices.Test\
194
- exec { & dotnet $script :dotnetTestArgs $script :NetRuntime.PS72 }
195
+ Exec { & dotnet $script :dotnetTestArgs $script :NetRuntime.PS72 }
195
196
}
196
197
197
- task TestE2E Build, SetupHelpForTests, {
198
+ Task TestE2E Build, SetupHelpForTests, {
198
199
Set-Location .\test\PowerShellEditorServices.Test.E2E\
199
200
200
201
$env: PWSH_EXE_NAME = if ($IsCoreCLR ) { " pwsh" } else { " powershell" }
201
202
$NetRuntime = if ($IsAppleM1 -or $script :IsArm64 ) { $script :NetRuntime.PS72 } else { $script :NetRuntime.PS7 }
202
- exec { & dotnet $script :dotnetTestArgs $NetRuntime }
203
+ Exec { & dotnet $script :dotnetTestArgs $NetRuntime }
203
204
204
- # Run E2E tests in ConstrainedLanguage mode.
205
205
if (! $script :IsNix ) {
206
206
if (-not [Security.Principal.WindowsIdentity ]::GetCurrent().Owner.IsWellKnown(" BuiltInAdministratorsSid" )) {
207
- Write-Warning ' Skipping E2E CLM tests as they must be ran in an elevated process.'
207
+ Write-Warning " Skipping Constrained Language Mode tests as they must be ran in an elevated process."
208
208
return
209
209
}
210
210
211
211
try {
212
+ Write-Host " Running end-to-end tests in Constrained Language Mode."
212
213
[System.Environment ]::SetEnvironmentVariable(" __PSLockdownPolicy" , " 0x80000007" , [System.EnvironmentVariableTarget ]::Machine);
213
- exec { & dotnet $script :dotnetTestArgs $script :NetRuntime.PS7 }
214
+ Exec { & dotnet $script :dotnetTestArgs $script :NetRuntime.PS7 }
214
215
} finally {
215
216
[System.Environment ]::SetEnvironmentVariable(" __PSLockdownPolicy" , $null , [System.EnvironmentVariableTarget ]::Machine);
216
217
}
217
218
}
218
219
}
219
220
220
- task LayoutModule - After Build {
221
+ Task LayoutModule - After Build {
221
222
$modulesDir = " $PSScriptRoot /module"
222
223
$psesVSCodeBinOutputPath = " $modulesDir /PowerShellEditorServices.VSCode/bin"
223
224
$psesOutputPath = " $modulesDir /PowerShellEditorServices"
@@ -226,8 +227,8 @@ task LayoutModule -After Build {
226
227
$psesCoreHostPath = " $psesBinOutputPath /Core"
227
228
$psesDeskHostPath = " $psesBinOutputPath /Desktop"
228
229
229
- foreach ($dir in $psesDepsPath , $psesCoreHostPath , $psesDeskHostPath , $psesVSCodeBinOutputPath ) {
230
- New-Item - Force - Path $dir - ItemType Directory
230
+ foreach ($dir in $psesDepsPath , $psesCoreHostPath , $psesDeskHostPath , $psesVSCodeBinOutputPath ) {
231
+ New-Item - Force - Path $dir - ItemType Directory | Out-Null
231
232
}
232
233
233
234
# Copy Third Party Notices.txt to module folder
@@ -310,7 +311,7 @@ task RestorePsesModules -After Build {
310
311
# Save each module in the modules.json file
311
312
foreach ($moduleName in $moduleInfos.Keys ) {
312
313
if (Test-Path - Path (Join-Path - Path $submodulePath - ChildPath $moduleName )) {
313
- Write-Host " `t Module '${moduleName} ' already detected. Skipping "
314
+ Write-Host " `t Module '${moduleName} ' already detected, skipping! "
314
315
continue
315
316
}
316
317
@@ -331,9 +332,9 @@ task RestorePsesModules -After Build {
331
332
}
332
333
333
334
Task BuildCmdletHelp - After LayoutModule {
334
- New-ExternalHelp - Path $PSScriptRoot \module\docs - OutputPath $PSScriptRoot \module\PowerShellEditorServices\Commands\en- US - Force
335
- New-ExternalHelp - Path $PSScriptRoot \module\PowerShellEditorServices.VSCode\docs - OutputPath $PSScriptRoot \module\PowerShellEditorServices.VSCode\en- US - Force
335
+ New-ExternalHelp - Path $PSScriptRoot \module\docs - OutputPath $PSScriptRoot \module\PowerShellEditorServices\Commands\en- US - Force | Out-Null
336
+ New-ExternalHelp - Path $PSScriptRoot \module\PowerShellEditorServices.VSCode\docs - OutputPath $PSScriptRoot \module\PowerShellEditorServices.VSCode\en- US - Force | Out-Null
336
337
}
337
338
338
339
# The default task is to run the entire CI build
339
- task . Clean , Build, Test
340
+ Task . Clean , Build, Test
0 commit comments