文章Install Extension By Name描述了如何通过市场名称从市场上安装扩展。
是否还可以在本地将扩展安装到Azure DevOps服务器?
步骤:server_ip/_gallery/manage
步骤:上传
以编程方式进行这些步骤非常好。
答案 0 :(得分:1)
根据docs,Azure DevOps Server 2019(甚至在TFS 2018中)也支持此Rest API:
https://{instance}/{collection}/_apis/extensionmanagement/installedextensionsbyname/{publisherName}/{extensionName}/{version}?api-version=5.0-preview.1
答案 1 :(得分:1)
用于基于.vsix
文件向Azure DevOps Server扩展库添加或删除扩展的PowerShell脚本:
$PAT = "PersonalAccessToken"
$Uri = "http://ip:port"
$timeout = 30
#AUTHORIZATION HEADERS
$headers = @{
"Authorization" = ('Basic {0}' -f [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($PAT)")))
"If-Match" = ""
}
#VARIABLE
$publisher = "YourPublisherName"
$extension = "YourExtensionName"
$vsix = "YourVsixPath.vsix"
#DELETE EXTENSION
$api = "api-version=5.0-preview.2"
$url = "$Uri/_apis/gallery/publishers/$publisher/extensions/$($extension)?$api"
$result = Invoke-RestMethod -Uri $url -Method DELETE -ContentType "application/json" -Headers $headers -TimeoutSec $timeout -Verbose
Write-Host $result
#ADD EXTENSION
$api = "api-version=3.0-preview.1"
$body = '{{"extensionManifest": "{0}"}}' -f ([Convert]::ToBase64String([IO.File]::ReadAllBytes($vsix)))
$url = "$Uri/_apis/gallery/extensions?$api"
$result = Invoke-RestMethod -Uri $url -Method POST -ContentType "application/json" -Headers $headers -Body $body -TimeoutSec $timeout -Verbose
Write-Host $result