Deploy Database Project with MSBuild with CommandLine Parameters fails
Asked Answered
G

0

9

I am failing to deploy Database project using command line parameters with msbuild. I would like to:

  • use publish xml profile
  • define connection string as command line parameter

but this seems to be impossible for no reason. There is for sure some simple catch I am missing. I tried following variants:

msbuild /t:SqlDeploy /p:SqlPublishProfilePath="test.publish.xml" /p:TargetConnectionString="Data Source=..." Database.sqlproj

  • deploys database
  • values in test.pubhlish.xml are ignored

msbuild /t:Build /t:Deploy /p:SqlPublishProfilePath="test.publish.xml" /p:TargetConnectionString="Data Source=..." Database.sqlproj

  • deploys database
  • values in test.pubhlish.xml are ignored

msbuild /t:Build /t:Publish /p:SqlPublishProfilePath="test.publish.xml" /p:TargetConnectionString="Data Source=..." Database.sqlproj

  • fails with error: Deploy Error : The connection string is not valid
  • values in test.publish.xml file are used (when test.publish.xml contains TargetConnectionString, database is deployed correctly)

In all 3 cases I am using exactly the same ConnectionString, so it is not a typo or error in the connection string. I need to use the 3rd variant, but this just fails.. What am I missing?

Guinn answered 11/3, 2017 at 23:36 Comment(3)
I am facing the same problem. It seems impossible to oversteeer the connection string from the publish profile. MSDeploy understands that though...Monotonous
@Lukas K did you ever find a solution to this? I'm having the same challenge.Cockscomb
kind of.. Have a look on SqlPackage.exe tool. It can publish DACPAC project with the option to pass connection string as parameter. You create DACPAC with msbuild and deploy it with SqlPackage. Hope this helps.Guinn

© 2022 - 2024 — McMap. All rights reserved.