按名称安装扩展一文描述了如何按名称从市场安装扩展。
是否也可以在本地将扩展安装到 Azure DevOps 服务器?
步:
server_ip/_gallery/manage
步骤:上传
- 步骤:安装
以编程方式完成这些步骤会很棒。
按名称安装扩展一文描述了如何按名称从市场安装扩展。
是否也可以在本地将扩展安装到 Azure DevOps 服务器?
步:server_ip/_gallery/manage
步骤:上传
以编程方式完成这些步骤会很棒。
用于将基于.vsix
文件的扩展添加或删除到 Azure DevOps 服务器扩展库的 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
根据文档,Azure DevOps Server 2019(甚至 TFS 2018)也支持这个 Rest API:
https://{instance}/{collection}/_apis/extensionmanagement/installedextensionsbyname/{publisherName}/{extensionName}/{version}?api-version=5.0-preview.1