[ci]Fail when something's wrong on multiline scripts

This commit is contained in:
Jaime Bernardo 2024-10-21 16:31:07 +01:00
parent db3c8e621e
commit ed39095c1b
3 changed files with 17 additions and 10 deletions

View File

@ -143,13 +143,19 @@ jobs:
- pwsh: |-
& '.pipelines/applyXamlStyling.ps1' -Passive
displayName: Verify XAML formatting
- pwsh: |-
& '.pipelines/verifyNugetPackages.ps1' -solution '$(build.sourcesdirectory)\PowerToys.sln'
displayName: Verify Nuget package versions for PowerToys.sln
- pwsh: |-
& '.pipelines/verifyArm64Configuration.ps1' -solution '$(build.sourcesdirectory)\PowerToys.sln'
& '.pipelines/verifyArm64Configuration.ps1' -solution '$(build.sourcesdirectory)\tools\BugReportTool\BugReportTool.sln'
& '.pipelines/verifyArm64Configuration.ps1' -solution '$(build.sourcesdirectory)\tools\WebcamReportTool\WebcamReportTool.sln'
& '.pipelines/verifyArm64Configuration.ps1' -solution '$(build.sourcesdirectory)\tools\StylesReportTool\StylesReportTool.sln'
& '.pipelines/verifyArm64Configuration.ps1' -solution '$(build.sourcesdirectory)\installer\PowerToysSetup.sln'
displayName: Verify formatting, nuget, and ARM64 configurations
displayName: Verify ARM64 configurations
- ${{ if eq(parameters.enablePackageCaching, true) }}:
- task: Cache@2

View File

@ -27,7 +27,7 @@ $arm64SlnConfigs = $solutionFile.SolutionConfigurations | Where-Object {
# Should have two configurations. Debug and Release.
if($arm64SlnConfigs.Length -lt 2) {
Write-Host -ForegroundColor Red "Missing Solution-level Arm64 platforms"
Write-Error -ForegroundColor Red "Missing Solution-level Arm64 platforms"
exit 1;
}
@ -51,13 +51,13 @@ foreach ($project in $projects) {
}
if ($errorTable.Count -gt 0) {
Write-Host -ForegroundColor Red "Verification failed for the following projects:`n"
Write-Error -ForegroundColor Red "Verification failed for the following projects:`n"
$errorTable.Keys | ForEach-Object {
Write-Host -ForegroundColor Red $_`:;
Write-Error -ForegroundColor Red $_`:;
$errorTable[$_] | ForEach-Object {
Write-Host -ForegroundColor Red "$($_.ExpectedConfiguration)=$($_.Configuration)";
Write-Error -ForegroundColor Red "$($_.ExpectedConfiguration)=$($_.Configuration)";
};
Write-Host -ForegroundColor Red `r
Write-Error -ForegroundColor Red `r
}
exit 1;
}

View File

@ -48,7 +48,7 @@ $totalFailure = 0;
Write-Host $DirPath;
if (-not (Test-Path $DirPath)) {
Write-Host "Folder does not exist!"
Write-Error "Folder does not exist!"
}
Write-Host "Total items: " $items.Count
@ -61,24 +61,25 @@ if ($items.Count -eq 0) {
$items | ForEach-Object {
if ($_.VersionInfo.FileVersion -eq "1.0.0.0" -and $_.Name -notmatch $versionExceptions) {
# These items are exceptions that actually have the 1.0.0.0 version.
Write-Host "Version set to 1.0.0.0: " + $_.FullName
Write-Error "Version set to 1.0.0.0: " + $_.FullName
$totalFailure++;
}
elseif ($_.VersionInfo.FileVersion -eq $null -and $_.Name -notmatch $nullVersionExceptions) {
# These items are exceptions that actually a version not set.
Write-Host "Version not set: " + $_.FullName
Write-Error "Version not set: " + $_.FullName
$totalFailure++;
}
else {
$auth = Get-AuthenticodeSignature $_.FullName
if ($auth.SignerCertificate -eq $null) {
Write-Host "Not Signed: " + $_.FullName
Write-Error "Not Signed: " + $_.FullName
$totalFailure++;
}
}
}
if ($totalFailure -gt 0) {
Write-Error "Some items had issues."
exit 1
}