Skip to content

Commit 0e61fa2

Browse files
authored
fix(build): capture dotnet stderr without aborting
1 parent 753828f commit 0e61fa2

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

build.ps1

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,16 @@ Write-Info "Runtime identifier: $rid"
287287

288288
$buildResults = @{}
289289

290+
function Invoke-DotNetCaptured($arguments) {
291+
$previousErrorActionPreference = $ErrorActionPreference
292+
$ErrorActionPreference = "Continue"
293+
try {
294+
return & dotnet @arguments 2>&1
295+
} finally {
296+
$ErrorActionPreference = $previousErrorActionPreference
297+
}
298+
}
299+
290300
function Build-Project($name, $path, $useRid = $false) {
291301
Write-Host "`nBuilding $name..." -ForegroundColor White
292302

@@ -295,12 +305,12 @@ function Build-Project($name, $path, $useRid = $false) {
295305
return $false
296306
}
297307

308+
$dotnetArgs = @("build", $path, "-c", $Configuration)
298309
# WinUI requires runtime identifier for self-contained WebView2 support
299310
if ($useRid) {
300-
$result = & dotnet build $path -c $Configuration -r $rid 2>&1
301-
} else {
302-
$result = & dotnet build $path -c $Configuration 2>&1
311+
$dotnetArgs += @("-r", $rid)
303312
}
313+
$result = Invoke-DotNetCaptured $dotnetArgs
304314
$exitCode = $LASTEXITCODE
305315

306316
if ($exitCode -eq 0) {

0 commit comments

Comments
 (0)