@@ -206,15 +206,48 @@ function Get-HashFromChecksumFile {
206
206
)
207
207
208
208
begin {
209
- $Args = @ {}
210
- if ($FileName ) {$Args .FileName = $FileName }
211
- else {$Args .Pattern = $Pattern }
209
+ $Arg = @ {}
210
+ if ($FileName ) {$Arg .FileName = $FileName }
211
+ else {$Arg .Pattern = $Pattern }
212
212
213
- return Get-HashFromChecksumText (Invoke-WebRequest $Uri ) @Args
213
+ return Get-HashFromChecksumText (Invoke-WebRequest $Uri ) @Arg
214
+ }
215
+ }
216
+
217
+ function Get-NugetRelease {
218
+ # ## . SYNOPSIS
219
+ # ## Lists all versions of a Nuget package.
220
+ [CmdletBinding (PositionalBinding = $false )]
221
+ param (
222
+ # ## Name of the Nuget package to retrieve releases for.
223
+ [Parameter (Mandatory , Position = 0 )]
224
+ [string ]
225
+ $PackageName ,
226
+ # ## Nuget feed URL to use. Defaults to the nuget.org feed.
227
+ # ## Must be a v3 Nuget feed, v2 is not supported.
228
+ [uri ]
229
+ $Feed = " https://api.nuget.org/v3/index.json"
230
+ )
231
+
232
+ begin {
233
+ $FeedIndex = Invoke-RestMethod $Feed
234
+ $PackageFeedUri = $FeedIndex.resources | ? " @type" -eq " PackageBaseAddress/3.0.0" | % " @id"
235
+
236
+ $pn = $PackageName.ToLowerInvariant ()
237
+ $PackageUri = $PackageFeedUri + $pn
238
+
239
+ Invoke-RestMethod " $PackageUri /index.json" | % versions | % {
240
+ # would be nice to also get the hash, but Nuget only provides sha-512, while we want sha-256
241
+ [pscustomobject ]@ {
242
+ VersionStr = $_
243
+ Version = [Pog.PackageVersion ]$_
244
+ Url = " $PackageUri /$_ /$pn .$_ .nupkg"
245
+ }
246
+ }
214
247
}
215
248
}
216
249
217
250
218
251
Export-ModuleMember `
219
252
- Cmdlet Get-UrlHash , Get-GithubRelease , Get-GithubAsset `
220
- - Function __main, Get-GithubAssetHash , Get-HashFromChecksumText , Get-HashFromChecksumFile
253
+ - Function __main, Get-GithubAssetHash , Get-HashFromChecksumText , Get-HashFromChecksumFile , Get-NugetRelease
0 commit comments