Beta 2 skip and replace rules

We posted about skip and replace rules awhile back, but this is probably one of the more complex areas of MS Deploy. You have to understand our provider structure to figure out what type of object needs to be replaced, what attribute, and then write a RegEx match. There are a lot of parameters you can set to scope the rules, and then the added complexity of regular expressions. So I wanted to post some of my favorite rules (not in priority order ;-)) for the command-line and also show the same rule for the PowerShell cmdlets.

If there are more rules that we should post as examples, please let me know!

1. Replace the home directory of a site or application

msdeploy -verb:sync -source:archiveDir=c:\App1 -dest:appHostconfig=MySite/App1 -replace:objectName=virtualDirectory,scopeAttributeName=physicalPath,match=c:\\inetpub\\wwwroot\\app1,replace=c:\dest\app1

I have an archive with an application that points to c:\inetpub\wwwroot\app1. I already have content in that location so when I sync, I want to create a new destination directory.

2. Replace multiple home directories for a site and child applications that have different paths

msdeploy -verb:sync -source:archiveDir=c:\NewSite1 -dest:appHostconfig=NewSite2 -replace:objectName=virtualDirectory,scopeAttributeName=physicalPath,match=c:\\inetpub\\wwwroot,replace=c:\dest2 -replace:objectName=virtualDirectory,scopeAttributeName=physicalPath,match=c:\\dest,replace=c:\dest3 -replace:objectName=virtualDirectory,scopeAttributeName=physicalPath,match=c:\\images,replace=c:\images2

I have an archive of a web site that contains a lot of directories. Most exist under c:\inetpub\wwwroot, and I likely already have content in this location, so I've decided to create a brand new site (just by specifying a new site name in the destination) and also change all the directories.

I use 3 replace rules for each different physical path I need to replace. My archive has a site with 5 applications, 3 underneath c:\inetpub\wwwroot and 2 under separate directories. In order to figure out all the paths I need to replace, I might know this in advance or I can open archive.xml in Notepad and search for every entry of ".dirPath". This will show me every place that we have a directory path.

3. Change the binding for a web site

msdeploy -verb:sync -source:package=site1.zip -dest:appHostconfig=MySite -replace:objectName=binding,targetAttributeName=bindingInformation,match=:80:,replace=:81:10.0.0.1

$dest = Get-DeploymentObject apphostconfig MySite
$source = Get-DeploymentObject archiveDir c:\FullSite
Update-DeploymentObject $dest $source -replace 'objectName=binding,targetAttributeName=bindingInformation,match=:80:,replace=:81:10.0.0.1'

In this case, I'm syncing from an archive that contains a site called Faith. With this sync, I am syncing it with a new name, MySite, to create a brand new site. I am also changing the port and adding an IP address. Note that it will change every binding that has matches :80: globally.

1 Comment

  • There isn't a way to send an e-mail to the blog, so forgive me for a little thread-jacking...

    I have a web app and a service and I would like the build script to check if the service has been updated since the last build and if so, run the "update service reference" script that is available when you right-click on a service. Is there a way to make this happen?

    Many thanks,

    Kevin Stevens
    Buffalo, NY

Comments have been disabled for this content.