/ .pipelines / verifyNugetPackages.ps1
verifyNugetPackages.ps1
 1  [CmdletBinding()]
 2  Param(
 3      [Parameter(Mandatory=$True,Position=1)]
 4      [string]$solution
 5  )
 6  
 7  Write-Host "Verifying Nuget packages for $solution"
 8  
 9  dotnet tool restore
10  dotnet consolidate -s $solution
11  if ($lastExitCode -ne 0)
12  {
13      $result = $lastExitCode
14      Write-Error "Error running dotnet consolidate, with the exit code $lastExitCode. Please verify logs and running environment."
15      exit $result
16  }
17  
18  if (-not $?)
19  {
20      Write-Host -ForegroundColor Red "Nuget packages with the same name must all be the same version."
21      exit 1
22  }
23  
24  # Ignore NU1503 on vcxproj files 
25  dotnet restore $solution /nowarn:NU1503 
26  if ($lastExitCode -ne 0)
27  {
28      $result = $lastExitCode
29      Write-Error "Error running dotnet restore, with the exit code $lastExitCode. Please verify logs on the nuget package versions."
30      exit $result
31  }
32  
33  exit 0