使用带有命令行参数的 MSBuild 部署数据库项目失败

Luk*_*s K 7 deployment msbuild publish database-project sql-server-data-tools

我无法通过 msbuild 使用命令行参数部署数据库项目。我想要:

  • 使用发布 xml 配置文件
  • 将连接字符串定义为命令行参数

但这似乎无缘无故地不可能。肯定有一些我遗漏的简单问题。我尝试了以下变体:

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

  • 部署数据库
  • test.pubhlish.xml 中的值被忽略

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

  • 部署数据库
  • test.pubhlish.xml 中的值被忽略

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

  • 失败并出现错误:Deploy Error : The connection string is not valid
  • 使用 test.publish.xml 文件中的值(当 test.publish.xml 包含 TargetConnectionString 时,数据库部署正确)

在所有 3 种情况下,我都使用完全相同的 ConnectionString,因此它不是连接字符串中的拼写错误或错误。我需要使用第三个变体,但这只是失败了..我错过了什么?