Using MS Deploy Instead of the Copy Command In MSBuild

written by Rob Aquila on Tuesday, April 07 2009

I currently use the copy command in msbuild to copy files out to machines in a deploy build.  I would match rather have a way to sync those directories with a source rather than just consistently dump files out to a target directory.  Using the msbuild copy command will copy the files but it will not remove files in the target directory that no longer exist in the source.  MS Deploy will do an actual compare to determine if it should update or delete files.  So I wanted a way to use MS Deploy in my build scripts.

I am currently able to use MS Deploy in the msbuild process by calling MS Deploy using an Exec command.  Here is an example of how its done.

<Exec Command=""C:\Program Files\IIS\Microsoft Web Deploy\msdeploy.exe" -verb:sync -source:contentpath="$(BinariesRoot)\Debug\_PublishedWebsites" -dest:contentpath="\\$(DEPLOY_SERVER_NAME)\$(WWW_DIR)\",computerName=$(DEPLOY_SERVER_NAME)"
          ContinueOnError
="false" />

In this example I’m copying the compiled web code from the build path out to a test machine.  Finally, you will need to install MS Deploy on the build machine for this to work.

Similar Posts

  1. MS Deploy Basics
  2. Using VSDBCMD and MSBUILD to Build and Deploy DBPro Projects
  3. MSBUILD DBPro Deploy Tip

Comments are closed

Options:

Size

Colors