您可以使用以下 powershell 脚本来提升多个包。此脚本假定所有包都具有相同的版本(一个产品由多个包组成)。它与我们的“DevOps Server 2019”配合良好。
param(
[Parameter(Mandatory=$True)]
[string]$tfsCollectionUri,
[Parameter(Mandatory=$True)]
[string]$feedName,
[Parameter(Mandatory=$True)]
[string]$packageVersion,
[Parameter(Mandatory=$True)]
[string]$packageQuality
)
$ErrorActionPreference = "Stop"
[regex]$nameExpression = "(?<name>[^0-9]*)\."
$json = '{ "views": { "op":"add", "path":"/views/-", "value":"' + $packageQuality + '" } }'
Write-Verbose -Message $json
Get-ChildItem . -Filter *.nupkg | Foreach-Object {
$matches = $nameExpression.Match($_.Name)
$packageName = $matches.groups['name']
$requestUri = $tfsCollectionUri + "/_apis/packaging/feeds/$feedName/nuget/packages/$packageName/versions/$packageVersion" + "?api-version=5.0-preview.1"
Write-Verbose -Message $requestUri
$reponse = Invoke-RestMethod -Uri $requestUri -UseDefaultCredentials -ContentType "application/json" -Method Patch -Body $json
Write-Verbose -Message "Response: '$reponse'"
}
该参数packageQuality
应该是例如“Release”或“Prerelease”,不带前导“@”。
非常感谢Shayki Abramczyk提供了正确方向的提示。