问题
I am trying to use msdeploy using dbDacFx provider to deploy my dacpac file. This database project uses a variable named UserName to create logins and users etc. Value for this needs to be passed during deployment time.
So i am doing something like ...
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"
but i get the following ( and by the way the url in the error message does not exist)
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.
how can one user SqlCmd variables with DbDacFx provider in MSDeploy ?
thanks
回答1:
I will confirm that I get the same error. Ahmed Elsayed's article http://www.iis.net/learn/publish/using-web-deploy/dbdacfx-provider-for-incremental-database-publishing, aside from having egregious typos, doesn't address sqlcmd variables either. I personally couldn't find the "real" reference like one would normally expect, such as the one for dbSqlPackage. Furthermore, I found unexplained anecdotal and allegorical variation between "-setParam:kind" and "-setParam:type". Again without documentation to back it up and without having an actual working solution, it does appear that scope can be a filename (regular expression). That said, I've also seen partial snippets by which the authors are defining scope as the provider to which one assigns the parameter. Richard's stuff has worked for me in the past, so am I comfortable moving forward with his suggestion.
回答2:
The scope
of a SqlCommandVariable
parameter should be the filename you are applying it to, not the provider:
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"
来源:https://stackoverflow.com/questions/13093101/using-sqlcmd-variables-with-dbdacfx-provider-of-msdeploy