Skip to content

Commit

Permalink
Add ability to capture MSBuild Binary logs when restore fails (PowerS…
Browse files Browse the repository at this point in the history
…hell#24128)

* Capture binary logs

* Update .pipelines/PowerShell-Coordinated_Packages-Official.yml
  • Loading branch information
TravisEz13 authored and chrisdent-de committed Sep 12, 2024
1 parent 2dc35ce commit b5b4229
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .pipelines/PowerShell-Coordinated_Packages-Official.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ parameters:
displayName: Enable Windows Stage
type: boolean
default: true
- name: ENABLE_MSBUILD_BINLOGS
displayName: Enable MSBuild Binary Logs
type: boolean
default: false

resources:
repositories:
Expand Down Expand Up @@ -68,6 +72,8 @@ variables:
value: ${{ parameters.SKIP_SIGNING }}
- group: 'AzDevOpsArtifacts'
- group: 'mscodehub-feed-read-akv'
- name: ENABLE_MSBUILD_BINLOGS
value: ${{ parameters.ENABLE_MSBUILD_BINLOGS }}

extends:
template: v2/OneBranch.Official.CrossPlat.yml@onebranchTemplates
Expand Down
21 changes: 21 additions & 0 deletions build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,10 @@ function Restore-PSPackage
$RestoreArguments += "--interactive"
}

if ($env:ENABLE_MSBUILD_BINLOGS) {
$RestoreArguments += '-bl'
}

$ProjectDirs | ForEach-Object {
$project = $_
Write-Log -message "Run dotnet restore $project $RestoreArguments"
Expand All @@ -870,6 +874,23 @@ function Restore-PSPackage
$retryCount++
if($retryCount -ge $maxTries)
{
if ($env:ENABLE_MSBUILD_BINLOGS) {
if ( Test-Path ./msbuild.binlog ) {
if (!(Test-Path $env:OB_OUTPUTDIRECTORY -PathType Container)) {
$null = New-Item -path $env:OB_OUTPUTDIRECTORY -ItemType Directory -Force -Verbose
}

$projectName = Split-Path -Leaf -Path $project
$binlogFileName = "${projectName}.msbuild.binlog"
if ($IsMacOS) {
$resolvedPath = (Resolve-Path -Path ./msbuild.binlog).ProviderPath
Write-Host "##vso[artifact.upload containerfolder=$binLogFileName;artifactname=$binLogFileName]$resolvedPath"
} else {
Copy-Item -Path ./msbuild.binlog -Destination "$env:OB_OUTPUTDIRECTORY/${projectName}.msbuild.binlog" -Verbose
}
}
}

throw
}
continue
Expand Down

0 comments on commit b5b4229

Please # to comment.