1

All the deployments in my work place are manual. I have been looking at ways to automate all of this using MSBUILD and MS Web Deploy. What I have managed to get working is as follows:

  • build/compile solutions
  • run database migrations
  • deploy directly to website using ms web deploy

All from one MSBUILD script.

This differs slightly from the manual process, as when a new version of a website is deployed manually, it is put into a new folder that is datetime stamped. And then IIS is pointed to the new folder.

My question is, how would I do these last 2 actions? i.e. write to a specific folder that sits a level higher up than the folder the current website points to, and then repoint to the new folder IIS.

eyeballpaul
  • 1,725
  • 2
  • 25
  • 39

1 Answers1

0

Web Deploy does not support this functionality directly. Thankfully it does provide the runCommand provider, which is what you'll end up using.

%windir%\system32\inetsrv\appcmd.exe is the utility you'll use to swap site directories. An example of usage can be found here: How do I change the physical path of web site in IIS7 with APPCMD?

  1. Create a script that calls appcmd. This script will always sit on your destination server. You can either decide to include it as a part of your site deployment, or move it along into the new directory from the old one. The "web deploy user" on the destination machine needs to have the appropriate credentials and access to create directories.

  2. In your MSBUILD script, prior to deployment, call the script on the destination server. E.g.

    msdeploy.exe -verb:sync -source:runcommand="C:\path\to\wwwroot\bin\script.bat" -dest:auto,wmsvc=https://contoso.com:8172/msdeploy.axd,username=%username%,password=%password%

  3. Then deploy as usual

NOTE: Try to avoid this way of deploying entirely. If you're looking to snapshot your site, consider deploying to a package (zip), and then deploying that package to your destination server. Rollbacks should be handled by deploying an older package, not by repointing to an older directory.

Community
  • 1
  • 1
DaveG.
  • 31
  • 3