File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -89,7 +89,19 @@ param(
8989
9090 [string []]$Define = @ (),
9191
92- [switch ]$ShowOutput
92+ [switch ]$ShowOutput ,
93+
94+ # When set, the result object is written as compressed JSON to this file path.
95+ # Used by Invoke-BuildPipeline to capture structured results from the subprocess
96+ # while still streaming build output to the console via | Out-Host.
97+ [string ]$OutputFile ,
98+
99+ # Output format for the result object.
100+ # object (default) -- emits a PSCustomObject to the pipeline.
101+ # json -- emits a single compressed JSON line; used by Invoke-BuildPipeline
102+ # to capture structured results from the subprocess.
103+ [ValidateSet (' object' , ' json' )]
104+ [string ]$Format = ' object'
93105)
94106
95107Set-StrictMode - Version Latest
@@ -345,7 +357,15 @@ try {
345357 output = $buildResult.Output
346358 }
347359
348- Write-Output $resultObj
360+ if (-not [string ]::IsNullOrWhiteSpace($OutputFile )) {
361+ Set-Content - LiteralPath $OutputFile - Value ($resultObj | ConvertTo-Json - Depth 5 - Compress) - Encoding UTF8
362+ }
363+
364+ if ($Format -eq ' json' ) {
365+ Write-Output ($resultObj | ConvertTo-Json - Depth 5 - Compress)
366+ } else {
367+ Write-Output $resultObj
368+ }
349369
350370 if ($buildResult.ExitCode -ne 0 ) {
351371 if ($ShowOutput ) {
You can’t perform that action at this time.
0 commit comments