Automated Web Deployment with MSBuild and MSDeploy

If you are looking for an automated web deployment process you will inevitably come to MSBuild.
There are many tutorials out there how to set up a command line call for MSBuild but you wont find a documentation how to publish a generated package with MSDeploy.

But this is especially needed is you want to use “-setParam” for a tokenized (transformed) web.config file and wont / can't change the SetParameter.xml!
(The names of the parameters for -setParam can be found in the SetParameter.xml file in the same directory as the They are also act as default values if not set in the command line call. )

So I wrote this quick tutorial how to get command line call for MSDeploy.
(Please consider that the paths you will later use are absolute / relative to the working directory.)

Step 1: Get the publish ready with MSBuild

Before we will get some further results please get your deployment call working.


Step 2: Get the command line for MSDeploy

Append the parameter /P:UseMsdeployExe=True to the msbuild.exe call. If you do so, you will see the call in the console like this:

Start Web Deploy Publish the Application/package to https:/TargetServer/MsDeploy.axd?site=TargetWebSite...
Running msdeploy.exe.
msdeploy.exe -source:package='C:\SomeWebProject\obj\Release\Package\' -dest:auto,ComputerName='https://TargetServer:8172/MsDeploy.axd?site=TargetWebSite',UserName='Username',Password='Password',IncludeAcls='False',AuthType='Basic' -verb:sync -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension -allowUntrusted -retryAttempts=2

Gotcha! This is the important MSDeploy command line call.

Step 3: Get the two things together

now we can split the automatic deployment of MSBuild into 1. create only the package with MSBuild and 2. only deploy with MSDeploy.


-setParam:'IIS Web Application Name'='TargetWebSite/TargetWebApp'

Have a nice day.

comments powered by Disqus