I'm now working on constructing build & deploy ASP.NET applications to several IIS Web servers. I use MSBuild and MSDeploy commands. To be specific, making a zip package of ASP.NET application on CI server and deploy it to Web servers. A zip packaged can be deployed with *.cmd file automatically generated by MSBuild command, but I want to use MSDeploy command in C# code because I automate some operations like service in and out from a load balancer with C# code.
Finally I found the way to execute MSDeploy in C# code. However there are few documentation about it... I describe how to write it.
First, install "Web Deploy 3.5" into Web servers and deploying client (and also your development machine). After installed, add
"Microsoft.Web.Deployment.dll" reference to your project. It locates at
C:\Program Files\IIS\Microsoft Web Deploy V3. A sample code is here.
There are many parameters in MSDeploy configurations. Please see the comment.
Sample execution result is here.
BytesCopied: 6487389 Added: 118 Updated: 4 Deleted: 0 Errors: 0 Warnings: 0 ParametersChanged: 0 TotalChanges: 122
It's much better this way because it's easy to write exception handling than MSDeploy command line.
(This post is an English Translation of my original Japanese post.)