使用SqlCmd变量与MsDeploy的dbDacFx提供程序

时间:2012-10-26 19:21:11

标签: .net sql-server-2008-r2 msdeploy webdeploy

我正在尝试使用msdeploy使用dbDacFx提供程序来部署我的dacpac文件。此数据库项目使用名为UserName的变量来创建登录名和用户等。需要在部署期间传递此值。

所以我正在做类似......

msdeploy.exe -verb:Sync -Source:dbDacFx="c:\dev\pmwuiservices\trunk\Build\database\Database.dacpac"-dest:dbDacFx="Data Source=localhost;Integrated Security=True;Database=UIConfig", -setParam:Kind=SqlCommandVariable,scope=dbDacFx,match=UserName,value="IIS AppPool\ASP.NET V4.0"

但我得到以下内容(并且错误消息中的url不存在)

Info: Adding MSDeploy.dbDacFx (MSDeploy.dbDacFx).
Info: Adding database (data source=localhost;integrated security=True;database=U
IConfig)
Info: Creating deployment plan: Pending.
Info: Verifying deployment plan: Pending.
Info: Deploying package to database: Pending.
Info: Creating deployment plan: Running.
Info: Initializing deployment (Start)
Info: Initializing deployment (Failed)
Info: Creating deployment plan: Faulted.
Info: Verifying deployment plan: Faulted.
Info: Deploying package to database: Faulted.
Error Code: ERROR_EXECUTING_METHOD
More Information: Could not deploy package.
Missing values for the following SqlCmd variables:UserName.
  Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_EXECUTING_M
ETHOD.
Error: Could not deploy package.
Error: Missing values for the following SqlCmd variables:UserName.
Error count: 1.

如何在MSDeploy中使用DbDacFx提供程序的一个用户SqlCmd变量?

感谢

2 个答案:

答案 0 :(得分:1)

我会确认我得到了同样的错误。 Ahmed Elsayed的文章http://www.iis.net/learn/publish/using-web-deploy/dbdacfx-provider-for-incremental-database-publishing,除了有严重的错别字外,也没有解决sqlcmd变量问题。我个人无法找到像通常所期望的“真实”引用,例如dbSqlPackage的引用。此外,我发现“-setParam:kind”和“-setParam:type”之间存在无法解释的轶事和寓意变异。再次没有备份文档而没有实际工作解决方案,看起来范围似乎是文件名(正则表达式)。也就是说,我也看到了部分片段,作者将范围定义为提供者,并为其分配参数。理查德的东西过去对我有用,所以我很乐意继续推进他的建议。

答案 1 :(得分:0)

scope参数的SqlCommandVariable应该是您应用它的文件名,而不是提供者:

msdeploy.exe -verb:sync ^
    -Source:dbDacFx="c:\dev\pmwuiservices\trunk\Build\database\Database.dacpac"
    -dest:dbDacFx="Data Source=localhost;Integrated Security=True;Database=UIConfig" 
    -setParam:kind=SqlCommandVariable,scope=Database.dacpac$,match=UserName,value="IIS AppPool\ASP.NET V4.0"