Quantcast
Channel: Forum SQL Server Database Engine
Viewing all articles
Browse latest Browse all 15694

DACPAC powershell deployment issue

$
0
0

Hi,

I am using SQLServer 2008 R2 with SP1 and getting an error while deploying a DACPAC by using powershell script. The DACPAC has been generated by using MS VisualStudio 2010 Version 10.0.402191 SP1Rel.

 

Powershell script :

#####################################################################
# started powershell script code #####################################################################

## Set variables.

$logFile = "C:\Temp\DBDeploymentLog.txt"
$serverName = "TestServer"
$userName = "user"
$password = "password"
$dacpacPath = "C:\Temp\Database.dacpac"
$dacName  = "SPStore"


$break = "`n----------------Starting Database Deployment---------------------------------"
Add-Content $logFile $break

$msg = "`nStarting DB creation: " +  (date -format "yyyy-MM-dd:HH-mm-ss")
Add-Content $logFile $msg

[Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo")
[Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Management.Sdk.Sfc")
[Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Management.Dac")
[Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.ConnectionInfo")

$serverConnection = New-Object Microsoft.SqlServer.Management.Common.ServerConnection($serverName, $userName, $password)
$sqlStoreConnection = New-Object Microsoft.SqlServer.Management.Sdk.Sfc.SqlStoreConnection($serverConnection.SqlConnectionObject)

$sqlStoreConnection.Connect()
Echo ------------Connected-----------------

$newDacStore = New-Object Microsoft.SqlServer.Management.Dac.DacStore($sqlStoreConnection)
$fileStream = [System.IO.File]::Open($dacpacPath, [System.IO.FileMode]::OpenOrCreate)

ECHO -------------Loading FIlestream-------------------
$dacType = [Microsoft.SqlServer.Management.Dac.DacType]::Load($fileStream)
ECHO -------------Loaded FIlestream-------------------

$newDacStore.add_DacActionStarted({Write-Host `n`nStarting at $(get-date) :: $_.Description})
$newDacStore.add_DacActionFinished({Write-Host Completed at $(get-date) :: $_.Description})

$evaluateTSPolicy = $true
$deployProperties = New-Object Microsoft.SqlServer.Management.Dac.DatabaseDeploymentProperties($serverconnection,$dacName)

$msg = "`nDeploying new instance of database"
Add-Content $logFile $msg

ECHO -------------DEPLOYING-------------------
$newDacStore.Install($dacType, $deployProperties, $evaluateTSPolicy)
ECHO -------------DEPLOYING-------------------

$fileStream.Close()

 

#####################################################################
# Finished powershell script code ####################################################################

 

 

I am able to connect to database and getting the following error in line "New-Object Microsoft.SqlServer.Management.Dac.DacStore($sqlStoreConnection)"

error :

New-Object : Cannot find an overload for "DacStore" and the argument count: "1".
At C:\temp\DACPAC Installation.ps1:32 char:26
+ $newDacStore = New-Object <<<<  Microsoft.SqlServer.Management.Dac.DacStore($sqlStoreConnection)
    + CategoryInfo          : InvalidOperation: (:) [New-Object], MethodException
    + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand

 

Anybody has encountered the same error and any help would be appreciated.

Thanks,

Prav

 


Viewing all articles
Browse latest Browse all 15694

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>