Intro
A common scenario of a team build solution is deploying the application on a nightly basis to provide the test team with an up-to-date deployment to test against. Such early visibility will help maintain the quality of the product over the development lifecycle.
The types of projects we work on commonly have a web application component, be it a front end or in the form of WebServices. Using the Microsoft SDC Task Library extensions for MSBUILD, web applications can be automatically deployed and configured under IIS 6.0/7.0 relatively easily.
Into Practice
The SDC Task Library is freely available at http://codeplex.com/sdctasks, the library isn’t limited to deploying websites, tasks include the functionality to execute SQL scripts, run installers, edit xml files and much more.
Download the library and add the Microsoft.Sdc.Tasks.dll assembly somewhere under your solution in source control so it is available during the build process.
To reference a task in the library from you MSBUILD script add a UsingTask. Set the AssemblyFile to the location of the assembly relative to the script and set the TaskName to the name of the Sdc task you want to use including the namespace.
<UsingTask AssemblyFile="Microsoft.Sdc.Tasks.dll" TaskName="Microsoft.Sdc.Tasks.Web.WebSite.Create"/>
Call the Task from within a Target in the usual way, so for example to create a new Website on a server somewhere:
<Create
MachineName="$(MachineName)"
Description="$(WebsiteName)"
Path="$(Path)"
Port="$(Port)"/>
Each of the Tasks are well documented in the compiled help file, which is included in the download.
Troubleshooting
-
The user that your Team Build Service runs as on the build machine must be an administrator on the machine that is hosting the web application
-
If you are deploying to IIS 7.0 you need to have the IIS 6.0 Management Compatibility services installed
- IIS including the compatibility services must be installed on BOTH the build server and the remote machine hosting the website.
This is because; under the covers the Task queries IIS on the remote machine over AD and IIS providers are needed on the remote and the client machine.
If this isn’t setup correctly you will get a ComException from DirectoryServices with an HRESULT of 0x80005000