Skip to content

Commit 07f21b7

Browse files
committed
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.
1 parent e1ee2f5 commit 07f21b7

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

azure-pipelines.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,13 +222,13 @@ stages:
222222
displayName: Restore
223223
inputs:
224224
filePath: eng/build.ps1
225-
arguments: -configuration Release -prepareMachine -ci -restore -binaryLog
225+
arguments: -configuration Release -prepareMachine -ci -restore -binaryLogName Restore.binlog
226226

227227
- task: PowerShell@2
228228
displayName: Build
229229
inputs:
230230
filePath: eng/build.ps1
231-
arguments: -configuration Release -prepareMachine -ci -build -pack -publish -sign -binaryLog
231+
arguments: -configuration Release -prepareMachine -ci -build -pack -publish -sign -binaryLogName Build.binlog
232232

233233
- script: $(Build.SourcesDirectory)\artifacts\bin\BuildBoss\Release\net472\BuildBoss.exe -r "$(Build.SourcesDirectory)/" -c Release -p Roslyn.sln
234234
displayName: Validate Build Artifacts
@@ -326,7 +326,7 @@ stages:
326326
displayName: Restore
327327
inputs:
328328
filePath: eng/build.ps1
329-
arguments: -configuration Debug -prepareMachine -ci -restore -binaryLog
329+
arguments: -configuration Debug -prepareMachine -ci -restore -binaryLogName Restore.binlog
330330

331331
- powershell: .\eng\test-rebuild.ps1 -ci -configuration Release
332332
displayName: Run BuildValidator

eng/build.ps1

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ param (
3434
[switch]$bootstrap,
3535
[string]$bootstrapConfiguration = "Release",
3636
[switch][Alias('bl')]$binaryLog,
37+
[string]$binaryLogName = "",
3738
[switch]$buildServerLog,
3839
[switch]$ci,
3940
[switch]$collectDumps,
@@ -79,6 +80,7 @@ function Print-Usage() {
7980
Write-Host " -verbosity <value> Msbuild verbosity: q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]"
8081
Write-Host " -deployExtensions Deploy built vsixes (short: -d)"
8182
Write-Host " -binaryLog Create MSBuild binary log (short: -bl)"
83+
Write-Host " -binaryLogName Name of the binary log (default Build.binlog)"
8284
Write-Host " -buildServerLog Create Roslyn build server log"
8385
Write-Host ""
8486
Write-Host "Actions:"
@@ -166,13 +168,21 @@ function Process-Arguments() {
166168
$script:applyOptimizationData = $false
167169
}
168170

171+
if ($binaryLogName -ne "") {
172+
$script:binaryLog = $true
173+
}
174+
169175
if ($ci) {
170176
$script:binaryLog = $true
171177
if ($bootstrap) {
172178
$script:buildServerLog = $true
173179
}
174180
}
175181

182+
if ($binaryLog -and ($binaryLogName -eq "")) {
183+
$binaryLogName = "Build.binlog"
184+
}
185+
176186
$anyUnit = $testDesktop -or $testCoreClr
177187
if ($anyUnit -and $testVsi) {
178188
Write-Host "Cannot combine unit and VSI testing"
@@ -213,7 +223,16 @@ function BuildSolution() {
213223

214224
Write-Host "$($solution):"
215225

216-
$bl = if ($binaryLog) { "/bl:" + (Join-Path $LogDir "Build.binlog") } else { "" }
226+
$bl = ""
227+
if (binaryLog) {
228+
$binaryLogPath = Join-Path $LogDir $binaryLogName
229+
$bl = "/bl:" + $binaryLogPath
230+
if ($ci -and Test-Path $binaryLogPath) {
231+
Write-LogIssue -Type "warning" -Message "Overwriting binary log file $($binaryLogPath)"
232+
}
233+
234+
}
235+
$bl = if ($binaryLog) { "/bl:" + (Join-Path $LogDir $binaryLogName) } else { "" }
217236

218237
if ($buildServerLog) {
219238
${env:ROSLYNCOMMANDLINELOGFILE} = Join-Path $LogDir "Build.Server.log"
@@ -734,7 +753,7 @@ try {
734753
catch
735754
{
736755
if ($ci) {
737-
echo "##vso[task.logissue type=error](NETCORE_ENGINEERING_TELEMETRY=Build) Build failed"
756+
Write-LogIssue -Type "error" -Message "(NETCORE_ENGINEERING_TELEMETRY=Build) Build failed"
738757
}
739758
throw $_
740759
}
@@ -752,7 +771,7 @@ try {
752771
catch
753772
{
754773
if ($ci) {
755-
echo "##vso[task.logissue type=error](NETCORE_ENGINEERING_TELEMETRY=Test) Tests failed"
774+
Write-LogIssue -Type "error" -Message "(NETCORE_ENGINEERING_TELEMETRY=Build) Tests failed"
756775
}
757776
throw $_
758777
}

0 commit comments

Comments
 (0)