PowerToys/.pipelines/verifyNoticeMdAgainstNugetPackages.ps1
Clint Rutkas 3fb707f78d
[ci]Verify notice.md and NuGet packages are synced (#23000)
* Create verifyNoticeMdAgainstNugetPackages.ps1

* Update build-powertoys-steps.yml

* Update verifyNoticeMdAgainstNugetPackages.ps1

* Update verifyNoticeMdAgainstNugetPackages.ps1

* Update build-powertoys-steps.yml

* Update build-powertoys-steps.yml

* Update NOTICE.md

* Update NOTICE.md

* Update NOTICE.md

* Update verifyNoticeMdAgainstNugetPackages.ps1

* Update verifyNoticeMdAgainstNugetPackages.ps1

* adding back in the Community Toolkit items

weird, some how there was a checkin with this being removed

* Update .pipelines/verifyNoticeMdAgainstNugetPackages.ps1

Co-authored-by: Jeremy Sinclair <4016293+snickler@users.noreply.github.com>

* Update .pipelines/verifyNoticeMdAgainstNugetPackages.ps1

Co-authored-by: Jeremy Sinclair <4016293+snickler@users.noreply.github.com>

* Update .pipelines/verifyNoticeMdAgainstNugetPackages.ps1

Co-authored-by: Jeremy Sinclair <4016293+snickler@users.noreply.github.com>

* Update .pipelines/verifyNoticeMdAgainstNugetPackages.ps1

Co-authored-by: Jeremy Sinclair <4016293+snickler@users.noreply.github.com>

* shifting the restore for setup back to where it was plus moving the verification to end.

* moved wrong powershell, fliping back

Co-authored-by: Jeremy Sinclair <4016293+snickler@users.noreply.github.com>
2023-01-09 12:27:57 +00:00

74 lines
1.9 KiB
PowerShell

[CmdletBinding()]
Param(
[Parameter(Mandatory=$True,Position=1)]
[string]$path
)
$noticeFile = Get-Content -Raw "NOTICE.md"
Write-Host $noticeFile
Write-Host "Verifying NuGet packages"
$projFiles = Get-ChildItem $path -Filter *.csproj -force -Recurse
$projFiles.Count
Write-Host "Going through all csproj files"
$totalList = $projFiles | ForEach-Object -Parallel {
$csproj = $_
$nugetTemp = @();
#Workaround for preventing exit code from dotnet process from reflecting exit code in PowerShell
$procInfo = New-Object System.Diagnostics.ProcessStartInfo -Property @{
FileName = "dotnet.exe";
Arguments = "list $csproj package";
RedirectStandardOutput = $true;
RedirectStandardError = $true;
}
$proc = [System.Diagnostics.Process]::Start($procInfo);
while (!$proc.StandardOutput.EndOfStream) {
$nugetTemp += $proc.StandardOutput.ReadLine();
}
$proc = $null;
$procInfo = $null;
if($nugetTemp -is [array] -and $nugetTemp.count -gt 3)
{
$temp = New-Object System.Collections.ArrayList
$temp.AddRange($nugetTemp)
$temp.RemoveRange(0, 3)
foreach($p in $temp)
{
# breaking item down to usable array and getting 1 and 2, see below of a sample output
# > PACKAGE VERSION VERSION
$p = -split $p
$p = $p[1, 2]
$tempString = $p[0] + " " + $p[1]
if(![string]::IsNullOrWhiteSpace($tempString))
{
echo "- $tempString";
}
}
$csproj = $null;
}
} -ThrottleLimit 4 | Sort-Object
$returnList = [System.Collections.Generic.HashSet[string]]($totalList) -join "`r`n"
Write-Host $returnList
if (!$noticeFile.Trim().EndsWith($returnList.Trim()))
{
Write-Host -ForegroundColor Red "Notice.md does not match NuGet list."
exit 1
}
exit 0