Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install procdump #3059

Merged
merged 4 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions azure-pipelines-official.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ extends:
filePath: './eng/install-windows-sdk.ps1'
failOnStderr: true
showWarnings: true

- task: PowerShell@2
displayName: 'Install procdump'
inputs:
targetType: filePath
filePath: ./eng/install-procdump.ps1
failOnStderr: true
showWarnings: true


- script: eng\common\CIBuild.cmd
-configuration $(_BuildConfig)
Expand Down
8 changes: 8 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ stages:
filePath: './eng/install-windows-sdk.ps1'
failOnStderr: true
showWarnings: true

- task: PowerShell@2
displayName: 'Install procdump'
inputs:
targetType: filePath
filePath: ./eng/install-procdump.ps1
failOnStderr: true
showWarnings: true

- script: eng\common\CIBuild.cmd
-configuration $(_BuildConfig)
Expand Down
99 changes: 99 additions & 0 deletions install-procdump.ps1
nohwnd marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
param(
[switch]$Force
)

function Download {
<#
.SYNOPSIS
Downloads a given uri and saves it to outputFile
.DESCRIPTION
Downloads a given uri and saves it to outputFile
PARAMETER uri
The uri to fetch
.PARAMETER outputFile
The outputh file path to save the uri
#>
param(
[Parameter(Mandatory = $true)]
$uri,

[Parameter(Mandatory = $true)]
$outputFile
)
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$ProgressPreference = 'SilentlyContinue' # Don't display the console progress UI - it's a huge perf hit

$maxRetries = 5
$retries = 1

while ($true) {
try {
Write-Host "GET $uri"
Invoke-WebRequest $uri -OutFile $outputFile
break
}
catch {
Write-Host "Failed to download '$uri'"
$error = $_.Exception.Message
}

if (++$retries -le $maxRetries) {
Write-Warning $error -ErrorAction Continue
$delayInSeconds = [math]::Pow(2, $retries) - 1 # Exponential backoff
Write-Host "Retrying. Waiting for $delayInSeconds seconds before next attempt ($retries of $maxRetries)."
Start-Sleep -Seconds $delayInSeconds
}
else {
Write-Error $error -ErrorAction Continue
throw "Unable to download file in $maxRetries attempts."
}
}

Write-Host "Download of '$uri' complete, saved to $outputFile..."

}

function Install-Procdump {
<#
.SYNOPSIS
Installs ProcDump into a folder in this repo.
.DESCRIPTION
This script downloads and extracts the ProcDump.
.PARAMETER Force
Overwrite the existing installation
#>
param(
[switch]$Force
)
$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue' # Workaround PowerShell/PowerShell#2138

Set-StrictMode -Version 1

$repoRoot = Resolve-Path "$PSScriptRoot\..\.."
$installDir = "$repoRoot\.tools\ProcDump\"

if (Test-Path "$installDir\procdump.exe") {
if ($Force) {
Remove-Item -Force -Recurse $installDir
}
else {
Write-Host "ProcDump already installed to $installDir. Exiting without action. Call this script again with -Force to overwrite."
exit 0
}
}

mkdir $installDir -ea Ignore | out-null
Write-Host "Starting ProcDump download"
Download "https://download.sysinternals.com/files/Procdump.zip" "$installDir/ProcDump.zip"
Write-Host "Done downloading ProcDump"
Expand-Archive "$installDir/ProcDump.zip" -d "$installDir"
Write-Host "Expanded ProcDump to $installDir"

if ($env:TF_BUILD) {
Write-Host "##vso[task.setvariable variable=PROCDUMP_PATH]$installDir"
Write-Host "##vso[task.prependpath]$installDir"
}
}

Install-Procdump -Force:$Force
Loading