2
Vote

TFS Deployer is unable to deploy database using SqlPackage

description

It seems that TFS Deployer is unable to use SqlPackage to deploy database to SQL Server.

PowerShell script is working fine if it is executed directly from command line but it fails when TFS Deployer tries to execute it, the same user account is used for both cases.

The service is running in test mode (TfsDeployer -d), as console application, but it also fails when runs as Windows Service.

This is log file (captured output of SqlPackage and exception caught in PowerShell script):
11/18/2012 17:51:49 | Publishing to database 'databaseName' on server 'machineName'.
11/18/2012 17:51:56 | An error occurred while the batch was being executed.
11/18/2012 17:51:56 | System.Management.Automation.RemoteException: *** Could not deploy package.
These are the only information I was able to collect. Error code (HRESULT) was not present in the caught exception.

PowerShell script goes like this:
try{
    $cmd = Join-Path (Get-Item "Env:ProgramFiles(x86)").Value "Microsoft SQL Server\110\DAC\bin\SqlPackage.exe"
    $src = Join-Path $sourcePath "db.dacpac"
    $cfg = Join-Path $sourcePath "db.publish.xml"

    &$cmd /Action:Publish /SourceFile:$src /Profile:$cfg 2>&1 | ForEach-Object -Process {
        Write-Log $_
    }
}
catch [Exception] {
    Write-Log $_.Exception.ToString()
    if($_.Exception.HResult) {
        Write-Log "Code: $($_.Exception.HResult.ToString('X'))"
    }
}

comments

jstangroome wrote Nov 21, 2012 at 10:21 AM

Which version of TFS Deployer?

kataklinger wrote Nov 21, 2012 at 10:37 AM

Oops, i forgot to mention. It is 1.5.2.0

JMiera wrote May 11, 2013 at 1:24 AM

On your SQL Server, do you have remote connections enabled?

Properties -> Connections -> "Allow remote connections to this server"

Also, take a look at the "Remarks" section of "System.Management.Automation.RemoteException" on MSDN:

http://msdn.microsoft.com/en-us/library/system.management.automation.remoteexception(v=vs.85).aspx