3

I am deploying a dacpac using sqlpackage.exe and need to pass SqlCMD variables for a postdeployment script in the dacpac. I found a related question here and here.

But i am getting the following error: Missing values for the following SqlCmd variables:BuildVersion Description. Description=$Description : The term 'Description=$Description' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Please help me.

Community
  • 1
  • 1
user2082197
  • 31
  • 1
  • 2

2 Answers2

4

The correct switch for passing a SQLCMD variable to SQLPackage is like this /v:Description=$Description

Powershell quoting is a bit tricky. Here's an example for you:

https://gist.github.com/davoscollective/adf9b890984e51d8dee2

& "C:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin\sqlpackage.exe" ` #Note this is SQL Server 2012 specific directory, alter as needed
/Action:Publish `
/SourceFile:$sourceFile `
/TargetServerName:$targetServerName `
/TargetDatabaseName:$targetDBname `
/V:SQLCMDVariable1=$SQLCMDVariable1 ` #If your project includes other database references, or pre/post deployment scripts uses SQLCMD variables
/v:SQLCMDVariable2=$SQLCMDVariable2 `
Davos
  • 5,066
  • 42
  • 66
1

It seems like you are using Powershell to call SqlPackage based on the cmdlet error. If this is the case ensure the Dollar symbols are escaped with a inverted apostrophe i.e.

ie Description=`$Description

Could you post the full command you are passing?

Eugene Niemand
  • 721
  • 6
  • 28