Synching an ASP.NET application to a local deployment folder with MSDeploy
In my recent quest to fine-tune the deployment process for bundl.it I’ve been investigating Microsoft’s new Web Deployment Tool, a.k.a MSDeploy. Recently released into v1.0, here’s what the IIS site says about it:
The Web Deployment Tool simplifies the migration, management and deployment of IIS Web servers, Web applications and Web sites.
It sounded interesting so I started playing with it in earnest this past weekend.
My first step was to use the command-line tool to sync a staged ASP.NET application from a staging folder to a mock, local deployment folder to see how this tool would behave:
[bash]msdeploy.exe –verb:sync –source:dirPath=c:\dev\bundl.it\www\staged -dest:dirPath=c:\dev\bundl.it\www\deployed[/bash]
Note: when running this from Powershell 1.0 on a Windows XP machine I got an error that looked like Powershell was swallowing the –verb, –source, and –dest arguments as powershell parameters. With cmd.exe it worked, and the issue seems to have gone away this morning with Powershell 2.0 on Windows 7.
In any case, this worked like a charm. The tool made changes to the destination path until it was a mirror of the source path, all the while spitting out diagnostic messages like:
[bash]Info: Updating filePath (c:\dev\bundl.it\www\deployed\bin\bundl.it.dll) Total changes: 1 (0 added, 0 deleted, 1 updated, 0 parameters changed, 32452 bytes copied)[/bash]
This was encouraging! That Total changes line implied that it would do much more than a simple XCopy-style deployment, so I went to my staging folder and deleted my web.config folder then ran the sync again. Here’s the output:
[bash]Info: Deleting filePath (c:\dev\bundl.it\www\deployed\Web.config) Total changes: 1 (0 added, 1 deleted, 0 updated, 0 parameters changed, 0 bytes copied)[/bash]
That’s exactly what I hoped for; files removed from our staging folder will get pruned out of production.
Next up, I’m looking to verify that MSDeploy will work for me to syncronize to a remote folder over FTP. After that I plan to expand on Eric Hexter’s recent MSDeploy examples and integrate MSDeploy into our MSBuild script. I’ll share the result in a few days.