我有一个 azure devops powershell 构建任务,它会引发警告,但是我不确定如何在构建日志中捕获这些警告。
2018-10-31T18:19:37.9619067Z WARNING: [13:19:37][Publish-DbaDacPackage] Deployment failed | DropExtendedPropertiesNotInSource conflicts with the
2018-10-31T18:19:37.9621270Z selected DoNotDropObjectType ExtendedProperties
示例代码:
try
{
$dacpac = "$($ArtifactPath)\DatabaseProjects\$($db)\bin\$($BuildConfig)\$($db).dacpac"
$publishProfile = "$($ArtifactPath)\DatabaseProjects\$($db)\$($db).publish.xml"
Publish-DbaDacPackage -SqlInstance $Sql -Database $db -Path $dacpac -PublishXml $publishProfile -GenerateDeploymentScript -ScriptOnly -OutputPath $OutPath
}
Catch
{
$ErrorMessage = $_.Exception.Message
$FailedItem = $_.Exception.ItemName
Write-Host " The database: $($db) failed during process. See error message here: $($ErrorMessage)."
Write-Host " Failed item: $($FailedItem)"
}
非常感谢任何帮助!