Skip to content

Instantly share code, notes, and snippets.

@mattleibow
Last active March 16, 2021 05:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattleibow/06a24d531df2068335fe536be294d538 to your computer and use it in GitHub Desktop.
Save mattleibow/06a24d531df2068335fe536be294d538 to your computer and use it in GitHub Desktop.
$source = 'https://pkgs.dev.azure.com/xamarin/public/_packaging/SkiaSharp/nuget/v3/index.json'
$check = 'https://pkgs.dev.azure.com/xamarin/6fd3d886-57a5-4e31-8db7-52a1b47c07a8/_packaging/737d9830-bed0-4b55-8699-c93e7b529ed0/nuget/v3/flat2/PACKAGE_ID/PACKAGE_VERSION/PACKAGE_ID.PACKAGE_VERSION.nupkg'
$nupkgs = (Get-ChildItem *.nupkg)
$total = $nupkgs.Count
Write-Host "Total: $total"
$counter = 0;
foreach ($nupkg in $nupkgs) {
$fname = $nupkg.Name.Replace('.nupkg', '').ToLower()
Write-Host "START: $fname"
$fname -match '([A-Za-z\.]+)\.(.*)' | Out-Null
$cUrl = $check.Replace('PACKAGE_ID', $Matches[1]).Replace('PACKAGE_VERSION', $Matches[2])
try {
$request = [System.Net.WebRequest]::Create($curl)
$response = $request.GetResponse()
$status = $response.StatusCode
$response.Close()
} catch {
$status = "Not Found"
}
if ($status -ne 'OK') {
dotnet nuget push $nupkg --source $source --api-key az --skip-duplicate --timeout 3000
}
$counter++;
$percent = "{0:P}" -f ($counter / $total)
Write-Host "END: $fname ($percent)"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment