Monday, May 6, 2013

How to Automate App Deployment in TeamCity (Part 2)

Please notice that this is a multi-part, step-by-step guide, on how to automate application deployment in TeamCity CI Server. You can find the Part 1 here.

Part 2: Configuring the Web Application in IIS7

To make the point and test what is the current outcome, we need to setup a web site in our IIS server. I’m using IIS7 for this scenario. 

Let’s run through a basic setup so we can actually test.

1. Login into your server machine.
2. Run the IIS Manager.
3. Right click on Sites, and select Add New Website


4. Fill in the new website details as you need. In my case I’m naming the site “”, letting IIS to create the corresponding application pool with the same name. Then enter the correct physical path, which is where the our deploy step is copying the files. I’m going to enter the same web site name as my domain name and leave it with the default IP Address and port.


5. Click ok. The new website should be added.
6. Click on the Content View on the center view to make sure the website directory is pointing to the right location and app files are there.


7. Now, since I don’t actually own that domain name, what I would do is configure a local domain setup. The site won’t be available publicly, but it will be available locally, so we can test.
8. To make the local domain work, you need to add a hosts record on the server machine. Open the hosts file, which is located at C:\Windows\System32\drivers\etc. Add the “” record pointing to the localhost IP address:


9. Save the file. If Windows doesn’t allow you to save the file, you need to create a copy somewhere else, do the changes and then replace the original file with the modified one.
10. Now, on the IIS Manager, right click on the website you created, and select Manage Web Site/Browse to open the browser and browse to our web app.


11. You will get a 403 HTTP Forbidden error. Basically, there’s no app to serve the web request, and the server won’t allow contents to be listed.


If you want to actually test your web app files on your server real quick to make sure the IIS web site setup is correct, you can actually do a simple file system publish from Visual Studio to package and publish your app files.







Then just delete the files on the server’s web site folder and copy the ones you published in your local machine.


Ok, so now we know that our basic deploy step is just a basic file copying step. This setup might be useful for other kind of apps, where just copying the compiled files might be enough. However, for our web app, we need to actually do a proper web deploy.

Next Article: Part 3 – Completing the Web Deploy Configuration

No comments:

Post a Comment