Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set destination website on MSDeploy.exe command line

I have a Web Deploy 3.5 package that I want to deploy to a remote server. How do I specify the name of the site on the MSDeploy.exe command line?

Here's what I have so far:

C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe
    -source:package='package.zip' 
    -dest:auto,computerName="ServerName",includeAcls="False" 
    -verb:sync 
    -disableLink:AppPoolExtension 
    -disableLink:ContentExtension 
    -disableLink:CertificateExtension 
    -setParamFile:"package.SetParameters.xml"

But the name of the site is specified in the package.SetParamters.xml file, and I'd prefer to set it on the command line. Some of the places I want to deploy this package are different sites located on the same server, like our Stage and UAT sites.

I've looked at using the iisApp and appHostConfig providers described here: http://technet.microsoft.com/en-us/library/dd569040%28v=ws.10%29.aspx

But I'm having trouble using those in combination with a package file.

like image 217
dthrasher Avatar asked Jan 10 '14 23:01

dthrasher


People also ask

What does MSDeploy exe do?

Overview. Web Deploy (msdeploy) simplifies deployment of Web applications and Web sites to IIS servers. Administrators can use Web Deploy to synchronize IIS servers or to migrate to newer versions of IIS.

How do I Deploy a web deployment package?

Create a web deployment package using the MSBuild command line, Team Build, or Visual Studio 2010. Copy the web package to the destination web server. Use the Import Application Package Wizard in IIS Manager to install the web package and provide values for variables like connection strings and service endpoints.

Where is MSDeploy installed?

Once the command prompt is up, you will navigate to the folder level where MSDeploy.exe exists. On Windows 7, the default installation will place msdeploy.exe in C:\Program Files (x86)\IIS\Microsoft Web Deploy. msdeploy.exe has an extensive command base.


2 Answers

You can override it using setParam:

msdeploy.exe
    -source:package='package.zip' 
    -dest:auto,computerName="ServerName",includeAcls="False" 
    -verb:sync 
    -disableLink:AppPoolExtension 
    -disableLink:ContentExtension 
    -disableLink:CertificateExtension 
    -setParamFile:"package.SetParameters.xml"
    -setParam:name="IIS Web Application Name",value="site name"
like image 86
Richard Szalay Avatar answered Mar 04 '23 03:03

Richard Szalay


To do the same in Powershell (see Richard Szalay's answer), you have to be a little careful about the command line argument handling - especially where spaces are involved. I find that it is best to pass them as an array where the desired command line arguments are effectively split on the space character. Note that the lines below are comma separated and also that the parameter name 'IIS Web Application' is split. I left that one on one line for improved readability.

$msdeploy = "C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe";

$msdeployArguments = 
    '-source:package="package.zip"',
    '-dest:auto,computerName="<ServerName>",includeAcls="False"',
    '-verb:sync',
    '-disableLink:AppPoolExtension',
    '-disableLink:ContentExtension',
    '-disableLink:CertificateExtension',
    '-setParam:name="IIS', 'Web', 'Application', 'Name",value="<WebsiteName>"'

& $msdeploy $msdeployArguments

Update

I had problems when I went back to parametrize the website Name. Because I had used single quotes for the strings, I chose to use concatenation rather than string interpolation. Unfortunately, the commas that delimited the elements in the array seem to have been evaluated prior to the concatenation. The result was that instead of concatenating strings within an array element, I was concatenating new elements to the array. My solution was to use parentheses to surround the array element and force the concatenation to be performed first.

$msdeployArguments = 
    '-source:package="package.zip"',
    ('-dest:auto,computerName="' + $webServerName + '",includeAcls="True"'),
    '-verb:sync',
    '-disableLink:AppPoolExtension',
    '-disableLink:ContentExtension',
    '-disableLink:CertificateExtension',
    '-setParam:name="IIS', 'Web', 'Application', ('Name",value="' + $websiteName + '"');
like image 37
Scott Munro Avatar answered Mar 04 '23 05:03

Scott Munro