通过 Azure Dev Ops API 调用创建分支时是否可以签入 DLL?
Is it Possible to Check-in a DLL When Creating a Branch through Azure Dev Ops API Call?
我想知道以下是否可能是任何形式。我正在关注此文档:create-a-new-branch 到目前为止,我可以通过 Postman 在 Dev Ops 中创建一个分支,并使用文本提交:
POST https://dev.azure.com/fabrikam/_apis/git/repositories/{repositoryId}/pushes?api-version=5.1
{
"refUpdates": [
{
"name": "refs/heads/myfirstbranch",
"oldObjectId": "b92a68a4cd54506d0d8e264ddddbfe5076dca910"
}
],
"commits": [
{
"comment": "Updating active tasks, but saving in a new branch.",
"changes": [
{
"changeType": "edit",
"item": {
"path": "/tasks/content/activetasks.md"
},
"newContent": {
"content": "# My Active Tasks\n\n* Item 1\n* Item 2\n* Item 3\n* Item 4\n* Item 5\n",
"contentType": "rawtext"
}
}
]
}
]
}
但是我需要能够在提交时提交一个 DLL(因为我的目标是能够通过管道完成这一切)并且文档说我唯一的值是:
有什么方法可以通过此 API 调用或通过 PowerShell 将 DLL 提交到我正在创建的新分支中吗?提前致谢!
从磁盘读取原始字节然后转换为 Base64:
# locate file
$dllFile = Get-Item .\path\to\dll
# open file stream to read file contents
$fileStream = $dllFile.OpenRead()
try {
# read file contents into buffer
$buffer = [byte[]]::new($dllFile.Length)
$readCount = $fileStream.Read($buffer, 0, $dllFile.Length)
# convert file contents to base64 string
$base64EncodedDLL = [Convert]::ToBase64String($buffer, 0, $readCount)
}
finally {
# clean up file stream handle
$fileStream.Dispose()
}
现在您只需将 $base64EncodedDLL
中存储的字符串值作为 content
属性 传递,并将 contentType
设置为 "base64encoded"
我想知道以下是否可能是任何形式。我正在关注此文档:create-a-new-branch 到目前为止,我可以通过 Postman 在 Dev Ops 中创建一个分支,并使用文本提交:
POST https://dev.azure.com/fabrikam/_apis/git/repositories/{repositoryId}/pushes?api-version=5.1
{
"refUpdates": [
{
"name": "refs/heads/myfirstbranch",
"oldObjectId": "b92a68a4cd54506d0d8e264ddddbfe5076dca910"
}
],
"commits": [
{
"comment": "Updating active tasks, but saving in a new branch.",
"changes": [
{
"changeType": "edit",
"item": {
"path": "/tasks/content/activetasks.md"
},
"newContent": {
"content": "# My Active Tasks\n\n* Item 1\n* Item 2\n* Item 3\n* Item 4\n* Item 5\n",
"contentType": "rawtext"
}
}
]
}
]
}
但是我需要能够在提交时提交一个 DLL(因为我的目标是能够通过管道完成这一切)并且文档说我唯一的值是:
有什么方法可以通过此 API 调用或通过 PowerShell 将 DLL 提交到我正在创建的新分支中吗?提前致谢!
从磁盘读取原始字节然后转换为 Base64:
# locate file
$dllFile = Get-Item .\path\to\dll
# open file stream to read file contents
$fileStream = $dllFile.OpenRead()
try {
# read file contents into buffer
$buffer = [byte[]]::new($dllFile.Length)
$readCount = $fileStream.Read($buffer, 0, $dllFile.Length)
# convert file contents to base64 string
$base64EncodedDLL = [Convert]::ToBase64String($buffer, 0, $readCount)
}
finally {
# clean up file stream handle
$fileStream.Dispose()
}
现在您只需将 $base64EncodedDLL
中存储的字符串值作为 content
属性 传递,并将 contentType
设置为 "base64encoded"