对于在 vsts 上手动构建并在线部署到 azure 的情况,一切正常。 但是当我从我的存储库触发相同的构建时,我得到了这个:
“找不到具有以下功能的代理:msbuild、visualstudio、sqlpackage”
如果我进入“构建定义”->“常规”选项卡
最佳答案
托管 VS2017 代理中没有 SqlPackage 功能。我在这里提交用户声音:VSTS SQL Package deploy with Hosted VS2017 agent .
解决方法是您可以通过 PowerShell 将 sql 包部署到 azure。
param(
[string]$publish_profile,
[string]$path_to_snapshots,
[string]$database
)
$psPath=$PSScriptRoot
write-output $psPath
Add-Type -Path "$psPath\lib\Microsoft.SqlServer.Dac.dll"
$dacProfile = [Microsoft.SqlServer.Dac.DacProfile]::Load($publish_profile)
$dacService = new-object Microsoft.SqlServer.Dac.DacServices($dacProfile.TargetConnectionString)
$files = Get-ChildItem "$path_to_snapshots\*.dacpac"
Write-Output $path_to_snapshots
Write-Output $files.Length
foreach ($file in $files)
{
$fileName = $file.Name
Try
{
Write-output $fileName
$dp = [Microsoft.SqlServer.Dac.DacPackage]::Load($file.FullName)
$dacService.Deploy($dp, $database, $true)
Start-Sleep -s 300
}
Catch
{
Write-Host "$fileName deployment has been failed" -foregroundcolor "red"
$Error | format-list -force
Write-Host $Error[0].Exception.ParentContainsErrorRecordException;
Break
}
}
相关主题:Deploy Dacpac packages via power shell script to Azure SQL Server
关于visual-studio - VSTS在线自动化构建找不到代理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43544833/