Passing Parameters in MS Web Deploy Command Line Deployment

4.4k Views Asked by At

I used msbuild to build a deployment package for my website. I am trying to use the generated deploy.cmd file located in the package to deploy to a remote server. I am using web deploy's parameters and I would like to set these at the command line using the -setParam flag.

The usage instructions for WebDeploy indicate that I need to enclose the -setParam configuration option in quotation marks because it contains an '=' character. However, the deploy.cmd file passes the entire option, including quotation marks, to the msdeploy executable. The msdeploy executable fails to run because the option does not start with the "-" character.

Error: Unrecognized argument '"-setParam:TestParam=ABC123"'. All arguments must begin with "-".

What do I need to do in order to get the setParam call working with the cmd file generated by msBuild?

2

There are 2 best solutions below

3
On

You don't need to wrap the entire parameter in quotes because of the equals sign. Just the parameter key and value because it may contain spaces.

-setParam:"TestParam"="ABC123"

should work for your example. Or in real world:

-setParam:"IIS Web Application Name"="example.com"
1
On

Have successfully used -setParam option in the following syntax, enclosing entire option in double quotes, and dubling double quotes inside:

...deploy.cmd "-setParam:name=""IIS Web Application Name"",value=""example.com"""