I have an automatic deployment script to deploy database changes using dacpac and sqlpackage.exe, SSRS reports and website.
When I run the script on the command line, sqlpackage displays the following message:
The object [objectname] already exists in the database with a different definition and will not be changed.
The console output is yellow, indicating that this is a warning, the deployment continues and completes as expected.
However, when I run the same script construct through TFS, the same message is logged in the build explorer, but an error icon appears next to it. Deployment is still ongoing, automatic tests are running, etc., but the build status changes to an icon with a mark and a cross in it - this means that the assembly completed successfully, but other tasks failed.
There is a parameter that can be provided in sqlpackage, UnmodifiableObjectWarnings, which should suppress this kind of warning, however there is a message in msdn indicating an error with this parameter, and this does not work.
, Powershell , , / - . sqlpackage, , .
:
https://serverfault.com/questions/340711/redirect-stderr-to-variable-in-powershell
:
try {
$test = & "C:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin\SqlPackage.exe" /SourceFile:"$dacpac" /Profile:"$dbProfile" /p:UnmodifiableObjectWarnings=True /Action:Publish 2>&1
$errMsg = $test | ?{$_.gettype().Name -eq "ErrorRecord"}
$normMsg = $test | ?{$_.gettype().Name -ne "ErrorRecord"}
}
catch {
Write-Host "Caught Exception $_"
}
, exe, - .
, :
try {
& "C:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin\SqlPackage.exe" /SourceFile:"$dacpac" /Profile:"$dbProfile" /p:UnmodifiableObjectWarnings=True /Action:Publish 2>&1
}
catch {
Write-Host "Caught Exception $_"
}
. $test capture, , . , , , ?