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

Add ability to capture MSBuild Binary logs when restore fails #24128

Merged
merged 2 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
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
Loading