$scriptRoot = Split-Path -Parent $MyInvocation.MyCommand.Path $jobs = @() $jobs += Start-Job -Name "DbMigrator" -ScriptBlock { $ErrorActionPreference = "Stop" Set-Location (Join-Path $using:scriptRoot "../../src/Hua.Abp.Demo.DbMigrator") dotnet run if ($LASTEXITCODE -ne 0) { throw "dotnet run (DbMigrator) exited with code $LASTEXITCODE" } } Wait-Job $jobs | Out-Null $failed = $jobs | Where-Object { $_.State -eq 'Failed' } $hasError = $failed.Count -gt 0 if ($hasError) { foreach ($job in $failed) { [Console]::Error.WriteLine("Job '$($job.Name)' FAILED") } Remove-Job $jobs | Out-Null exit -1 } Remove-Job $jobs | Out-Null exit 0