Cannot use pwsh local tool with arcade
The implementation of ExitWithExitCode means that we cannot use pwsh as a local tool in our repos. The implementation kills a number of processes, including dotnet. That means when you execute a script with dotnet pwsh example.ps1 the ExitWithExitCode will kill itself.
Example:
. "eng/common/tools.ps1"
$prepareMachine=$true
$ci=$true
ExitWithExitCode 0
Put that script in the root of a repo then execute it:
E:\code\wt\ros3
⚡🔨 > dotnet pwsh .\example.ps1
Killing running build processes...
E:\code\wt\ros3
⚡🔨 > $LASTEXITCODE
-1
Probably need to change Stop-Process to be
function Stop-Processes() {
Write-Host 'Killing running build processes Roslyn style...'
foreach ($processName in $processesToStopOnExit) {
Get-Process -Name $processName -ErrorAction SilentlyContinue
? { $_.ProcessId -ne $PID }
| Stop-Process
}
}
Really though, why we blanket kill dotnet here? What are we trying to achieve that forces us to do this?
Really though, why we blanket kill
dotnethere? What are we trying to achieve that forces us to do this?
I'm not sure of the history but suspect the process clean up is intended to ensure files are released before builds create artefacts.
In any case, there might be a workaround: Your builds could create a variable named processesToStopOnExit that's an array of strings naming what you want stopped. The default is @('msbuild', 'dotnet', 'vbcscompiler'). Passing @('msbuild', 'vbcscompiler') might do the trick for you @jaredpar.
If not, this seems like a quick fix. Feel free to open a PR 😁