$rootFolder = (Get-Item -Path "./" -Verbose).FullName $solutionPaths = @( "../" ) foreach ($solutionPath in $solutionPaths) { $solutionAbsPath = (Join-Path $rootFolder $solutionPath) Set-Location $solutionAbsPath dotnet build --configuration Release if (-Not $?) { Write-Host ("Build failed for the solution: " + $solutionPath) Set-Location $rootFolder exit $LASTEXITCODE } } Set-Location $rootFolder