UploadCores.ps1 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. param(
  2. [Parameter(Mandatory = $true)]
  3. [ValidateNotNullOrEmpty()]
  4. [string]$ProcDumpOutputPath
  5. )
  6. Set-StrictMode -Version 2
  7. $ErrorActionPreference = 'Stop'
  8. function Warn {
  9. [CmdletBinding()]
  10. param (
  11. [Parameter(Mandatory = $true)]
  12. [ValidateNotNullOrEmpty()]
  13. [string]$Message
  14. )
  15. Write-Warning "$Message"
  16. if ((Test-Path env:TF_BUILD) -and $env:TF_BUILD) {
  17. Write-Host "##vso[task.logissue type=warning]$Message"
  18. }
  19. }
  20. $repoRoot = Resolve-Path "$PSScriptRoot\..\.."
  21. $procDumpOutputPath = Join-Path $repoRoot $ProcDumpOutputPath
  22. if ((Test-Path env:SYSTEM_DEFAULTWORKINGDIRECTORY) -and $env:SYSTEM_DEFAULTWORKINGDIRECTORY) {
  23. if (Test-Path env:SYSTEM_PHASENAME) { $jobName = "$env:SYSTEM_PHASENAME" } else { $jobName = "$env:AGENT_OS" }
  24. $artifactName = "${jobName}_Dumps"
  25. $wd = $env:SYSTEM_DEFAULTWORKINGDIRECTORY
  26. } else {
  27. $artifactName = "Artifacts_Dumps"
  28. $wd = "$PWD"
  29. }
  30. [string[]]$files = Get-ChildItem "$wd\dotnet-*.core"
  31. if (Test-Path "$procDumpOutputPath") {
  32. $files += Get-ChildItem "${procDumpOutputPath}*.dmp"
  33. }
  34. if ($null -eq $files -or 0 -eq $files.Count) {
  35. Warn "No core files found."
  36. } else {
  37. foreach ($file in $files) {
  38. Write-Host "##vso[artifact.upload containerfolder=$artifactName;artifactname=$artifactName]$file"
  39. }
  40. }