diff --git a/Build-Sample.ps1 b/Build-Sample.ps1 index 8c614bd25..093ba1ed9 100644 --- a/Build-Sample.ps1 +++ b/Build-Sample.ps1 @@ -147,39 +147,42 @@ $myexit=0 # If we fail at first, but succeed at either of next two attempts, then it is a sporadic failure. # If we even at third attempt fail, then it is a true failure. # -for ($i=0; $i -le 2; $i++) { +for ($i = 0; $i -lt 3; $i++) +{ + $binLogFilePath = "$LogFilesDirectory\$SampleName.$Configuration.$Platform.$i.binlog" $errorLogFilePath = "$LogFilesDirectory\$SampleName.$Configuration.$Platform.$i.err" $warnLogFilePath = "$LogFilesDirectory\$SampleName.$Configuration.$Platform.$i.wrn" $OutLogFilePath = "$LogFilesDirectory\$SampleName.$Configuration.$Platform.$i.out" - 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 - if ($env:WDS_WipeOutputs -ne $null) + 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 + if ($null -ne $env:WDS_WipeOutputs) { - Write-Verbose ("WipeOutputs: "+$Directory+" "+(((Get-Volume ($DriveLetter=(Get-Item ".").PSDrive.Name)).SizeRemaining/1GB))) - Get-ChildItem -path $Directory -Recurse -Include x64|Remove-Item -Recurse - Get-ChildItem -path $Directory -Recurse -Include arm64|Remove-Item -Recurse + Write-Verbose ("WipeOutputs: " + $Directory + " " + (((Get-Volume (Get-Item ".").PSDrive.Name).SizeRemaining / 1GB))) + Get-ChildItem -path $Directory -Recurse -Include x64 | Remove-Item -Recurse + Get-ChildItem -path $Directory -Recurse -Include arm64 | Remove-Item -Recurse } if ($LASTEXITCODE -eq 0) { # We succeeded building. - # If at first attempt, then $myexit=0 - # If at later attempt, then $myexit=2 + # If it was at a later attempt, let the caller know with a different exit code. if ($i -eq 0) { - $myexit=0 + $myexit = 0 } else { - $myexit=2 + $myexit = 2 } - break; + # Remove binlog on success to save space; keep otherwise to diagnose issues. + Remove-Item $binLogFilePath + break; } else { # We failed building. # Let us sleep for a bit. # Then let the while loop do its thing and re-run. - sleep 1 + Start-Sleep 1 if ($Verbose) { Write-Warning "`u{274C} Build failed. Retrying to see if sporadic..." diff --git a/Build-SampleSet.ps1 b/Build-SampleSet.ps1 index f6765395a..270a7eaa1 100644 --- a/Build-SampleSet.ps1 +++ b/Build-SampleSet.ps1 @@ -14,7 +14,7 @@ $root = Get-Location if (-not $env:VSCMD_VER) { Import-Module (Resolve-Path "$env:ProgramFiles\Microsoft Visual Studio\2022\*\Common7\Tools\Microsoft.VisualStudio.DevShell.dll") Enter-VsDevShell -VsInstallPath (Resolve-Path "$env:ProgramFiles\Microsoft Visual Studio\2022\*") - cd $root + Set-Location $root } $ThrottleFactor = 5 @@ -97,7 +97,7 @@ else { # Dump all environment variables so as to help debug error: Write-Output "Environment variables {" - gci env:* | sort-object name + Get-ChildItem env:* | Sort-Object name Write-Output "Environment variables }" Write-Error "Could not determine build environment." @@ -105,11 +105,17 @@ else { } # # Get the WDK extension version from installed packages -$wdk_extension_ver = ls "${env:ProgramData}\Microsoft\VisualStudio\Packages\Microsoft.Windows.DriverKit,version=*" | Select -ExpandProperty Name +$wdk_extension_ver = Get-ChildItem "${env:ProgramData}\Microsoft\VisualStudio\Packages\Microsoft.Windows.DriverKit,version=*" | Select-Object -ExpandProperty Name $wdk_extension_ver = ([regex]'(\d+\.)(\d+\.)(\d+\.)(\d+)').Matches($wdk_extension_ver).Value if (-not $wdk_extension_ver) { - Write-Error "No version of the WDK Visual Studio Extension could be found. The WDK Extension is not installed." - exit 1 + # Be lenient with EWDK builds that do not include the package information + if ($build_environment -match '^EWDK') { + $wdk_extension_ver = "(package not found)" + } + else { + Write-Error "No version of the WDK Visual Studio Extension could be found. The WDK Extension is not installed." + exit 1 + } } # # @@ -348,7 +354,7 @@ $Results = $jresult.Results Write-Output "Built all combinations." Write-Output "" Write-Output "Elapsed time: $min minutes, $seconds seconds." -Write-Output ("Disk Remaining (GB): " + (((Get-Volume ($DriveLetter = (Get-Item ".").PSDrive.Name)).SizeRemaining / 1GB))) +Write-Output ("Disk Remaining (GB): " + (((Get-Volume (Get-Item ".").PSDrive.Name).SizeRemaining / 1GB))) Write-Output ("Samples: " + $sampleSet.Count) Write-Output ("Configurations: " + $Configurations.Count + " (" + $Configurations + ")") Write-Output ("Platforms: " + $Platforms.Count + " (" + $Platforms + ")")