Skip to content

Commit 6337ff0

Browse files
committed
Clarifications for Issue #17
All 54 tests pass
1 parent 91b275b commit 6337ff0

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

source/delphi-msbuild.ps1

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff 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

95107
Set-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) {

0 commit comments

Comments
 (0)