Go back

Using MSDeploy as a build task in TFS

MSDeploy is a new tool out by Microsoft that allows easy synching of files between servers. This can be used from inside IIS or just run from command line.

You can read more on MSDeploy here. Read MSDeploy's team blog. Nice article on using the msdeploy command line [link removed due to malware].

I thought I would share an actual use of the MSDeploy in our TFS build scripts. It also uses the XmlUpdate task from the MSBuild Community Tasks Project.

<Target Name="AfterDropBuild">

<!-- Update web.config to be in release mode -->
<XmlUpdate XPath="/configuration/system.web/compilation/@debug"
XmlFileName="$(DropLocation)$(BuildNumber)Release_Published
WebsitesSiteweb.config
" Value="false" />

<BuildStep TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
BuildUri="$(BuildUri)"
Message="Deploying Website"
Condition="'$(IsDesktopBuild)'!='true'" >
<
Output TaskParameter="Id" PropertyName="InstallerStepId" />
</
BuildStep>

<Exec
Command='"C:Program FilesIISMicrosoft Web Deploymsdeploy.exe"
-verb:sync
-source:contentpath="$(DropLocation)$(BuildNumber)
Release_PublishedWebsitesSite"
-dest:contentpath=\SERVERWebsitesSite
'
ContinueOnError="false" />

<BuildStep TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
BuildUri="$(BuildUri)"
Id="$(InstallerStepId)"
Status="Succeeded"
Condition="'$(IsDesktopBuild)'!='true'" />

<OnError ExecuteTargets="DeploymentFailed" />

</Target>

<Target Name="DeploymentFailed">
<!--
Called if deployment of the web site fails -->
<
BuildStep
TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
BuildUri="$(BuildUri)"
Id="$(InstallerStepId)"
Status="Failed"
Condition="'$(IsDesktopBuild)'!='true'" />
</
Target>

 

Got a project? Let's work together

Compsoft is a remote working company except for Thursdays when we work together from the Alton Maltings in Alton, Hampshire (UK). Our registered address is detailed below. We'd be delighted to have either a virtual chat with you or to make arrangements to meet in person.