From fbaa3e8b77b604830c3ad59936d14c00d88fc4da Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 21 Feb 2019 09:29:42 -0800 Subject: [PATCH] Always kill processes and remove direct reference to component governance task (#7793) --- .azure/pipelines/ci.yml | 4 ---- .azure/pipelines/jobs/default-build.yml | 17 ++++++++----- eng/scripts/KillProcesses.ps1 | 32 ++++++++++++++++--------- 3 files changed, 32 insertions(+), 21 deletions(-) diff --git a/.azure/pipelines/ci.yml b/.azure/pipelines/ci.yml index 707563c7c1..6c1d448e81 100644 --- a/.azure/pipelines/ci.yml +++ b/.azure/pipelines/ci.yml @@ -79,10 +79,6 @@ jobs: displayName: Run sign check condition: eq(variables['_SignType'], 'real') - # Detect OSS Components in use in the product. Only needs to run on one OS in the matrix. - - task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0 - displayName: Detect components - condition: and(succeeded(), eq(variables['system.pullrequest.isfork'], false)) artifacts: - name: Windows_Packages path: artifacts/packages/ diff --git a/.azure/pipelines/jobs/default-build.yml b/.azure/pipelines/jobs/default-build.yml index 06fff26d1a..eaeb9ace14 100644 --- a/.azure/pipelines/jobs/default-build.yml +++ b/.azure/pipelines/jobs/default-build.yml @@ -140,21 +140,26 @@ jobs: - ${{ if eq(parameters.agentOs, 'Windows') }}: - script: .\$(BuildDirectory)\build.cmd -ci /p:SignType=$(_SignType) /p:Configuration=$(BuildConfiguration) $(BuildScriptArgs) displayName: Run build.cmd - - powershell: eng\scripts\KillProcesses.ps1 - displayName: Kill processes - condition: always() - ${{ if ne(parameters.agentOs, 'Windows') }}: - script: ./$(BuildDirectory)/build.sh -ci -p:Configuration=$(BuildConfiguration) $(BuildScriptArgs) displayName: Run build.sh - - script: eng/scripts/KillProcesses.sh - displayName: Kill processes - condition: always() - ${{ if ne(parameters.buildScript, '') }}: - script: $(BuildScript) /p:Configuration=$(BuildConfiguration) $(BuildScriptArgs) displayName: run $(BuildScript) - ${{ parameters.afterBuild }} + - ${{ if eq(parameters.agentOs, 'Windows') }}: + - powershell: eng\scripts\KillProcesses.ps1 + displayName: Kill processes + continueOnError: true + condition: always() + - ${{ if ne(parameters.agentOs, 'Windows') }}: + - script: eng/scripts/KillProcesses.sh + displayName: Kill processes + continueOnError: true + condition: always() + - task: PublishTestResults@2 displayName: Publish test results condition: always() diff --git a/eng/scripts/KillProcesses.ps1 b/eng/scripts/KillProcesses.ps1 index 29b3657281..8df10e9f10 100644 --- a/eng/scripts/KillProcesses.ps1 +++ b/eng/scripts/KillProcesses.ps1 @@ -1,16 +1,26 @@ $ErrorActionPreference = 'Continue' -taskkill /T /F /IM dotnet.exe -taskkill /T /F /IM testhost.exe -taskkill /T /F /IM iisexpress.exe -taskkill /T /F /IM iisexpresstray.exe -taskkill /T /F /IM w3wp.exe -taskkill /T /F /IM msbuild.exe -taskkill /T /F /IM vbcscompiler.exe -taskkill /T /F /IM git.exe -taskkill /T /F /IM vctip.exe -taskkill /T /F /IM chrome.exe -taskkill /T /F /IM h2spec.exe +function _kill($processName) { + try { + # Redirect stderr to stdout to avoid big red blocks of output in Azure Pipeline logging + # when there are no instances of the process + & cmd /c "taskkill /T /F /IM ${processName} 2>&1" + } catch { + Write-Host "Failed to kill ${processName}: $_" + } +} + +_kill dotnet.exe +_kill testhost.exe +_kill iisexpress.exe +_kill iisexpresstray.exe +_kill w3wp.exe +_kill msbuild.exe +_kill vbcscompiler.exe +_kill git.exe +_kill vctip.exe +_kill chrome.exe +_kill h2spec.exe iisreset /restart exit 0