@@ -11,12 +11,13 @@ param(
1111
1212 [string ]$DefaultModuleRepository = " PSGallery" ,
1313
14+ [string []]$VerbosityArgs = @ (" --verbosity" , " quiet" , " --nologo" ),
15+
1416 # See: https://docs.microsoft.com/en-us/dotnet/core/testing/selective-unit-tests
1517 [string ]$TestFilter = ' ' ,
1618
1719 # 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" )
2021)
2122
2223# Requires -Modules @ {ModuleName = " InvokeBuild" ; ModuleVersion = " 5.0.0" }
@@ -38,9 +39,9 @@ $script:BuildInfoPath = [System.IO.Path]::Combine($PSScriptRoot, "src", "PowerSh
3839$script :PsesCommonProps = [xml ](Get-Content - Raw " $PSScriptRoot /PowerShellEditorServices.Common.props" )
3940
4041$script :NetRuntime = @ {
41- PS7 = ' netcoreapp3.1'
42- PS72 = ' net6.0'
43- Desktop = ' net462'
42+ PS7 = ' netcoreapp3.1'
43+ PS72 = ' net6.0'
44+ Desktop = ' net462'
4445 Standard = ' netstandard2.0'
4546}
4647
@@ -54,31 +55,31 @@ if (Get-Command git -ErrorAction SilentlyContinue) {
5455 git update-index -- assume- unchanged " $PSScriptRoot /src/PowerShellEditorServices.Hosting/BuildInfo.cs"
5556}
5657
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"
5960
6061 # Strip out semantic version metadata so it can be cast to `Version`
6162 $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"
6364
6465 # Anywhere other than on a Mac with an M1 processor, we additionally
6566 # need the .NET 3.1 runtime for our netcoreapp3.1 framework.
6667 if (-not $script :IsAppleM1 -and -not $script :IsArm64 ) {
6768 $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!"
6970 }
7071
7172 Write-Host " Using dotnet v$ ( dotnet -- version) at path $ ( (Get-Command dotnet).Source) " - ForegroundColor Green
7273}
7374
74- task BinClean {
75+ Task BinClean {
7576 Remove-Item $PSScriptRoot \.tmp - Recurse - Force - ErrorAction Ignore
7677 Remove-Item $PSScriptRoot \module\PowerShellEditorServices\bin - Recurse - Force - ErrorAction Ignore
7778 Remove-Item $PSScriptRoot \module\PowerShellEditorServices.VSCode\bin - Recurse - Force - ErrorAction Ignore
7879}
7980
80- task Clean FindDotNet, BinClean, {
81- exec { & dotnet clean }
81+ Task Clean FindDotNet, BinClean, {
82+ Exec { & dotnet clean $VerbosityArgs }
8283 Get-ChildItem - Recurse $PSScriptRoot \src\* .nupkg | Remove-Item - Force - ErrorAction Ignore
8384 Get-ChildItem $PSScriptRoot \PowerShellEditorServices* .zip | Remove-Item - Force - ErrorAction Ignore
8485 Get-ChildItem $PSScriptRoot \module\PowerShellEditorServices\Commands\en- US\*- help.xml | Remove-Item - Force - ErrorAction Ignore
@@ -93,7 +94,7 @@ task Clean FindDotNet, BinClean, {
9394 }
9495}
9596
96- task CreateBuildInfo {
97+ Task CreateBuildInfo {
9798 $buildVersion = " <development-build>"
9899 $buildOrigin = " Development"
99100 $buildCommit = git rev- parse HEAD
@@ -147,77 +148,77 @@ namespace Microsoft.PowerShell.EditorServices.Hosting
147148"@
148149
149150 if (Compare-Object $buildInfoContents.Split ([Environment ]::NewLine) (Get-Content $script :BuildInfoPath )) {
150- Write-Host " Updating Build Info "
151+ Write-Host " Updating build info. "
151152 Set-Content - LiteralPath $script :BuildInfoPath - Value $buildInfoContents - Force
152153 }
153154}
154155
155- task SetupHelpForTests {
156+ Task SetupHelpForTests {
156157 if (-not (Get-Help Write-Host ).Examples) {
157- Write-Host " Updating help for tests"
158+ Write-Host " Updating help for tests. "
158159 Update-Help - Module Microsoft.PowerShell.Utility - Force - Scope CurrentUser
159160 }
160161}
161162
162163Task 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 }
166167 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 }
168169 }
169170
170171 # 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 }
172173}
173174
174- task Test TestServer, TestE2E
175+ Task Test TestServer, TestE2E
175176
176- task TestServer TestServerWinPS, TestServerPS7, TestServerPS72
177+ Task TestServer TestServerWinPS, TestServerPS7, TestServerPS72
177178
178179Task TestServerWinPS - If (-not $script :IsNix ) Build, SetupHelpForTests, {
179180 Set-Location .\test\PowerShellEditorServices.Test\
180181 # TODO: See https://github.com/dotnet/sdk/issues/18353 for x64 test host
181182 # that is debuggable! If architecture is added, the assembly path gets an
182183 # additional folder, necesstiating fixes to find the commands definition
183184 # file and test files.
184- exec { & dotnet $script :dotnetTestArgs $script :NetRuntime.Desktop }
185+ Exec { & dotnet $script :dotnetTestArgs $script :NetRuntime.Desktop }
185186}
186187
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, {
188189 Set-Location .\test\PowerShellEditorServices.Test\
189- exec { & dotnet $script :dotnetTestArgs $script :NetRuntime.PS7 }
190+ Exec { & dotnet $script :dotnetTestArgs $script :NetRuntime.PS7 }
190191}
191192
192- task TestServerPS72 Build, SetupHelpForTests, {
193+ Task TestServerPS72 Build, SetupHelpForTests, {
193194 Set-Location .\test\PowerShellEditorServices.Test\
194- exec { & dotnet $script :dotnetTestArgs $script :NetRuntime.PS72 }
195+ Exec { & dotnet $script :dotnetTestArgs $script :NetRuntime.PS72 }
195196}
196197
197- task TestE2E Build, SetupHelpForTests, {
198+ Task TestE2E Build, SetupHelpForTests, {
198199 Set-Location .\test\PowerShellEditorServices.Test.E2E\
199200
200201 $env: PWSH_EXE_NAME = if ($IsCoreCLR ) { " pwsh" } else { " powershell" }
201202 $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 }
203204
204- # Run E2E tests in ConstrainedLanguage mode.
205205 if (! $script :IsNix ) {
206206 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."
208208 return
209209 }
210210
211211 try {
212+ Write-Host " Running end-to-end tests in Constrained Language Mode."
212213 [System.Environment ]::SetEnvironmentVariable(" __PSLockdownPolicy" , " 0x80000007" , [System.EnvironmentVariableTarget ]::Machine);
213- exec { & dotnet $script :dotnetTestArgs $script :NetRuntime.PS7 }
214+ Exec { & dotnet $script :dotnetTestArgs $script :NetRuntime.PS7 }
214215 } finally {
215216 [System.Environment ]::SetEnvironmentVariable(" __PSLockdownPolicy" , $null , [System.EnvironmentVariableTarget ]::Machine);
216217 }
217218 }
218219}
219220
220- task LayoutModule - After Build {
221+ Task LayoutModule - After Build {
221222 $modulesDir = " $PSScriptRoot /module"
222223 $psesVSCodeBinOutputPath = " $modulesDir /PowerShellEditorServices.VSCode/bin"
223224 $psesOutputPath = " $modulesDir /PowerShellEditorServices"
@@ -226,8 +227,8 @@ task LayoutModule -After Build {
226227 $psesCoreHostPath = " $psesBinOutputPath /Core"
227228 $psesDeskHostPath = " $psesBinOutputPath /Desktop"
228229
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
231232 }
232233
233234 # Copy Third Party Notices.txt to module folder
@@ -310,7 +311,7 @@ task RestorePsesModules -After Build {
310311 # Save each module in the modules.json file
311312 foreach ($moduleName in $moduleInfos.Keys ) {
312313 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! "
314315 continue
315316 }
316317
@@ -331,9 +332,9 @@ task RestorePsesModules -After Build {
331332}
332333
333334Task 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
336337}
337338
338339# The default task is to run the entire CI build
339- task . Clean , Build, Test
340+ Task . Clean , Build, Test
0 commit comments