Update on using MSDeploy for remote deployments.

This is a follow up to the post http://www.lostechies.com/blogs/hex/archive/2009/11/06/using-msdeploy-to-automate-your-enterprise-application-remote-deployments.aspx


The only trouble I have run into using this approach is that the runCommand does not bubble up error code or exit code from the command being executed on a remote machine.  This is a complete fail in my book.  You have to know that your process works and be notified when it does not.  In the mean time, the work around for my process works like this.

We kick this job off from Nant, so I capature the text output from the remote command, put it into a variable and than run a Regular Expression against it to determine if the remote process finished successfully or not.

Here is what this looks like in Nant ( oh.. that is some ugly xml)



So what is happening here?

The output of the exec command is being sent to a text file using the Output attribute.

The text file is then loaded into a variable called deploystep2.

The reg ex parses out the Build Success or Build Failed text from the file.

If build Failed is found than the <fail> tag fails the deployment and than the rest of our reporting process works as planned.



About Eric Hexter

I am the CTO for QuarterSpot. I (co)Founded MvcContrib, Should, Solution Factory, and Pstrami open source projects. I have co-authored MVC 2 in Action, MVC3 in Action, and MVC 4 in Action. I co-founded online events like mvcConf, aspConf, and Community for MVC. I am also a Microsoft MVP in ASP.Net.
This entry was posted in .Net, agile, Deployment, MSDeploy. Bookmark the permalink. Follow any comments here with the RSS feed for this post.
  • I use MSDeploy with Rake, here’s what I do:
    - Redirect the output to the console and a log file (using tee)
    - Read the log file after MSDeploy has exited
    - Scan the log file for “error” or “exception” and raising and exception if the log file happens to include these strings, telling where the log can be found.

    Basically it’s the same what you do with NAnt and I also find it to be a bit hacky for an “enterprisey” solution built by MS. Obviously they were not dogfooding their own tooling. If you’re interested, here’s a link to the Ruby file for MSDeploy:

    Sample usage:
    MSDeploy.run \
    :tool => configatron.tools.msdeploy,
    :log_file => configatron.deployment.logfile,
    :verb => :sync,
    :source => Dictionary[:contentPath, configatron.dir.deploy.to_absolute.escape],
    :dest => Dictionary[
    :wmsvc, configatron.deployment.server,
    :contentPath, configatron.deployment.location.escape,
    :username, configatron.deployment.user,
    :password, configatron.deployment.password
    :usechecksum => true,
    #:allowUntrusted => true,
    :skip => [
    :o bjectName, "filePath",
    :skipAction, "Delete",
    :absolutePath, "App_Offline\.htm$"
    :o bjectName, "dirPath",
    :skipAction, "Delete",
    :absolutePath, "Downloads$"

  • Jorge Matos


    Have you looked at the remoting features of PowerShell V2? If you have the luxury of installing PSV2 and WinRM on your target servers, you should be able to use PS to automate the deployment of your binary files plus the remote execution of any setup/test scripts. The best advantage of this is that you can do it all within the context of one PS script and any errors that occur remotely are returned to you locally.

  • Eric Hexter

    @Jorge, I have looked at it, part of what I am dealing with is using a firewall friendly port to communicate to the remote server. I did not think that Posh v2 could remote over port 80 or 443 like MSDeploy can. If they can be configured to run over those ports I am interested in exploring that approach. I think that this post demonstrates the MSDeploy is really version 1 and the main audiance microsoft is targeting is individual developers who would try to publish from visual studio directly to their web host, rather than make this part of an automated build process.