Skip to content

Commit

Permalink
Don't overwrite binary logs (#66559)
Browse files Browse the repository at this point in the history
* Don't overwrite binary logs

Several of our legs were calling `build.ps1 -binaryLog` in a row and
that re-uses the binary log file name which causes an overwrite. This
change allows us to specify the name and adds a warning if we do
accidentally overwrite in the future.

* enable trace for diff issue

* Work around NuGet static graph restore bug

NuGet/Home#12373
  • Loading branch information
Jared Parsons authored and dibarbet committed Apr 19, 2023
1 parent e5ddc47 commit c269944
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ jobs:
displayName: Restore
inputs:
filePath: eng/build.ps1
arguments: -configuration Debug -prepareMachine -ci -restore -binaryLog
arguments: -configuration Debug -prepareMachine -ci -restore -binaryLogName Restore.binlog

- powershell: .\eng\test-rebuild.ps1 -ci -configuration Release
displayName: Run BuildValidator
Expand Down
30 changes: 26 additions & 4 deletions eng/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ param (
[switch]$bootstrap,
[string]$bootstrapConfiguration = "Release",
[switch][Alias('bl')]$binaryLog,
[string]$binaryLogName = "",
[switch]$buildServerLog,
[switch]$ci,
[switch]$collectDumps,
Expand Down Expand Up @@ -78,6 +79,7 @@ function Print-Usage() {
Write-Host " -verbosity <value> Msbuild verbosity: q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]"
Write-Host " -deployExtensions Deploy built vsixes (short: -d)"
Write-Host " -binaryLog Create MSBuild binary log (short: -bl)"
Write-Host " -binaryLogName Name of the binary log (default Build.binlog)"
Write-Host " -buildServerLog Create Roslyn build server log"
Write-Host ""
Write-Host "Actions:"
Expand Down Expand Up @@ -165,13 +167,21 @@ function Process-Arguments() {
$script:applyOptimizationData = $false
}

if ($binaryLogName -ne "") {
$script:binaryLog = $true
}

if ($ci) {
$script:binaryLog = $true
if ($bootstrap) {
$script:buildServerLog = $true
}
}

if ($binaryLog -and ($binaryLogName -eq "")) {
$script:binaryLogName = "Build.binlog"
}

$anyUnit = $testDesktop -or $testCoreClr
if ($anyUnit -and $testVsi) {
Write-Host "Cannot combine unit and VSI testing"
Expand Down Expand Up @@ -212,7 +222,14 @@ function BuildSolution() {

Write-Host "$($solution):"

$bl = if ($binaryLog) { "/bl:" + (Join-Path $LogDir "Build.binlog") } else { "" }
$bl = ""
if ($binaryLog) {
$binaryLogPath = Join-Path $LogDir $binaryLogName
$bl = "/bl:" + $binaryLogPath
if ($ci -and (Test-Path $binaryLogPath)) {
Write-LogIssue -Type "warning" -Message "Overwriting binary log file $($binaryLogPath)"
}
}

if ($buildServerLog) {
${env:ROSLYNCOMMANDLINELOGFILE} = Join-Path $LogDir "Build.Server.log"
Expand All @@ -239,6 +256,11 @@ function BuildSolution() {
$generateDocumentationFile = if ($skipDocumentation) { "/p:GenerateDocumentationFile=false" } else { "" }
$roslynUseHardLinks = if ($ci) { "/p:ROSLYNUSEHARDLINKS=true" } else { "" }

# Temporarily disable RestoreUseStaticGraphEvaluation to work around this NuGet issue
# in our CI builds
# https://github.com/NuGet/Home/issues/12373
$restoreUseStaticGraphEvaluation = if ($ci) { $false } else { $true }

try {
MSBuild $toolsetBuildProj `
$bl `
Expand All @@ -258,7 +280,7 @@ function BuildSolution() {
/p:TreatWarningsAsErrors=$warnAsError `
/p:EnableNgenOptimization=$applyOptimizationData `
/p:IbcOptimizationDataDir=$ibcDir `
/p:RestoreUseStaticGraphEvaluation=true `
/p:RestoreUseStaticGraphEvaluation=$restoreUseStaticGraphEvaluation `
/p:VisualStudioIbcDrop=$ibcDropName `
/p:VisualStudioDropAccessToken=$officialVisualStudioDropAccessToken `
$suppressExtensionDeployment `
Expand Down Expand Up @@ -690,7 +712,7 @@ try {
catch
{
if ($ci) {
echo "##vso[task.logissue type=error](NETCORE_ENGINEERING_TELEMETRY=Build) Build failed"
Write-LogIssue -Type "error" -Message "(NETCORE_ENGINEERING_TELEMETRY=Build) Build failed"
}
throw $_
}
Expand All @@ -708,7 +730,7 @@ try {
catch
{
if ($ci) {
echo "##vso[task.logissue type=error](NETCORE_ENGINEERING_TELEMETRY=Test) Tests failed"
Write-LogIssue -Type "error" -Message "(NETCORE_ENGINEERING_TELEMETRY=Test) Tests failed"
}
throw $_
}
Expand Down
2 changes: 2 additions & 0 deletions eng/common/tools.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,8 @@ function MSBuild-Core() {

$env:ARCADE_BUILD_TOOL_COMMAND = "$($buildTool.Path) $cmdArgs"

Write-Host "Exec $($buildTool.Path) and $cmdArgs"

$exitCode = Exec-Process $buildTool.Path $cmdArgs

if ($exitCode -ne 0) {
Expand Down

0 comments on commit c269944

Please sign in to comment.