Skip to content

Commit eea6227

Browse files
committed
Improved readability and logging on Build-Sample script
1 parent 015d531 commit eea6227

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

Build-Sample.ps1

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -147,39 +147,42 @@ $myexit=0
147147
# If we fail at first, but succeed at either of next two attempts, then it is a sporadic failure.
148148
# If we even at third attempt fail, then it is a true failure.
149149
#
150-
for ($i=0; $i -le 2; $i++) {
150+
for ($i = 0; $i -lt 3; $i++)
151+
{
152+
$binLogFilePath = "$LogFilesDirectory\$SampleName.$Configuration.$Platform.$i.binlog"
151153
$errorLogFilePath = "$LogFilesDirectory\$SampleName.$Configuration.$Platform.$i.err"
152154
$warnLogFilePath = "$LogFilesDirectory\$SampleName.$Configuration.$Platform.$i.wrn"
153155
$OutLogFilePath = "$LogFilesDirectory\$SampleName.$Configuration.$Platform.$i.out"
154156

155-
msbuild $solutionFile -clp:Verbosity=m -t:rebuild -property:Configuration=$Configuration -property:Platform=$Platform -p:TargetVersion=Windows10 -p:InfVerif_AdditionalOptions="$InfVerif_AdditionalOptions" -warnaserror -flp1:errorsonly`;logfile=$errorLogFilePath -flp2:WarningsOnly`;logfile=$warnLogFilePath -noLogo > $OutLogFilePath
156-
if ($env:WDS_WipeOutputs -ne $null)
157+
msbuild $solutionFile -clp:Verbosity=m -t:rebuild -property:Configuration=$Configuration -property:Platform=$Platform -p:TargetVersion=Windows10 -p:InfVerif_AdditionalOptions="$InfVerif_AdditionalOptions" -warnaserror -binaryLogger:LogFile=$binLogFilePath`;ProjectImports=None -flp1:errorsonly`;logfile=$errorLogFilePath -flp2:WarningsOnly`;logfile=$warnLogFilePath -noLogo > $OutLogFilePath
158+
if ($null -ne $env:WDS_WipeOutputs)
157159
{
158-
Write-Verbose ("WipeOutputs: "+$Directory+" "+(((Get-Volume ($DriveLetter=(Get-Item ".").PSDrive.Name)).SizeRemaining/1GB)))
159-
Get-ChildItem -path $Directory -Recurse -Include x64|Remove-Item -Recurse
160-
Get-ChildItem -path $Directory -Recurse -Include arm64|Remove-Item -Recurse
160+
Write-Verbose ("WipeOutputs: " + $Directory + " " + (((Get-Volume (Get-Item ".").PSDrive.Name).SizeRemaining / 1GB)))
161+
Get-ChildItem -path $Directory -Recurse -Include x64 | Remove-Item -Recurse
162+
Get-ChildItem -path $Directory -Recurse -Include arm64 | Remove-Item -Recurse
161163
}
162164
if ($LASTEXITCODE -eq 0)
163165
{
164166
# We succeeded building.
165-
# If at first attempt, then $myexit=0
166-
# If at later attempt, then $myexit=2
167+
# If it was at a later attempt, let the caller know with a different exit code.
167168
if ($i -eq 0)
168169
{
169-
$myexit=0
170+
$myexit = 0
170171
}
171172
else
172173
{
173-
$myexit=2
174+
$myexit = 2
174175
}
175-
break;
176+
# Remove binlog on success to save space; keep otherwise to diagnose issues.
177+
Remove-Item $binLogFilePath
178+
break;
176179
}
177180
else
178181
{
179182
# We failed building.
180183
# Let us sleep for a bit.
181184
# Then let the while loop do its thing and re-run.
182-
sleep 1
185+
Start-Sleep 1
183186
if ($Verbose)
184187
{
185188
Write-Warning "`u{274C} Build failed. Retrying to see if sporadic..."

0 commit comments

Comments
 (0)