Tidbits on software development, technology, and other geeky stuff

Web Deploy (MS Deploy) from TeamCity

I use TeamCity as a continuous integration server but also as a build/deploy server. With the click of a button, TeamCity will build my solution, run unit tests and automatically deploy my web application to a server. This is awesome because:
  1. It saves tons of time as it automates the process.
  2. It ensures the integrity of the build before deploying (compile, run tests, halt if error).
  3. It allows me to encapsulate deployment logic so that there are no manual, “magic” steps involved with deployment. When I go on vacation, another developer can deploy my app with the same button click I use.
I could go on and on about the advantages of using a CI/build/deploy server for development but here I want to explain how to setup TeamCity to use the new Web Deploy (MS Deploy) tool to deploy ASP.NET Web Application projects to a server running IIS.

Setup Steps

  1. Install the Web Deployment Tool on your TeamCity server and the server you want to deploy your web application to (“target server”).
  2. On your target server, setup an administrator user account for use by TeamCity.
  3. Create a new project in TeamCity.
  4. Under Project Configuration, select “Build Parameters” option.
  5. Add Configuration Parameters and System Properties per the example below. Configuration Parameters
  6. Change the values highlighted in yellow above to your own values. A few notes:
    • build.file.directory = this is the *relative checkout path *of the folder which contains your web application .csproj file
    • system.DeployIISAppPath = the IIS website name on the target server which you want to deploy to. Yes, this means you need to configure IIS ahead of time if you are going to use anything other than the “Default Web Site” in IIS.
    • system.MsDeployServiceUrl = the server name or IP address of the target server.
    • system.UserName / system.Password = the username and password of the administrator account you setup earlier for the target server.
  7. Under Project Configuration, select “Build Steps” option and add a new Build Step (MSBuild runner type).
  8. Configure the new build step per the example below: Build Step
  9. Save the new TeamCity project.
  10. Run the project build and you’re done! The web application will be compiled and deployed to your server running IIS.

Next Steps

Credit and Reference

Discuss on Twitter