DEV Community

Cover image for Publish Web App from Visual Studio to IIS Using Web Deploy
Ahmed Hesham
Ahmed Hesham

Posted on • Updated on

Publish Web App from Visual Studio to IIS Using Web Deploy

Introduction

There are several ways you could publish your Web App from Visual Studio. The simplest way is to publish to a folder, then copy paste to the hosting server, IIS for example.

But it's always better to automate these operations; it makes them faster (no need to copy all files, just the changed ones), and less likely to cause mistakes (replace appsettings.json or web.config file).
It also opens the door to more advanced operations, like zero downtime deployment, which I plan to write about in the next post.

In this post I'll write about how to publish a Web App in Visual Studio to IIS using Web Deploy. When things are set up, you will only need to click the publish button in Visual Studio to publish your app.

What is Web Deploy?

Prerequisites

  • IIS 7
  • Visual Studio 2010

Steps

Note: The order of steps is important.

1. Install Web Management Service (WMSVC)

  1. In remote server, open Control Panel -> Turn Windows features on or off.
  2. Look for Internet Information Services (IIS) -> Management Tools -> check Management Service.
  3. Proceed to install.

Check Management Service

2. Download and Install Web Platform Installer (WebPI)

It's recommended to use WebPI instead of directly downloading tools; because WebPI also gets the dependencies and configures these tools depending on the current system settings.

Web Platform Installer

3. Get Web Deploy

  1. Open WebPI directly (start menu for example), not through IIS Manager.
  2. Search for Web Deploy, then install.

Install Web Deploy from WebPI

Note: If Web Deploy is already installed, uninstall it (from Control Panel, not repair), then repeat above steps.

4. Add Port 8172 to Exceptions

This port gets added automatically to Windows Firewall exceptions if you followed the above steps.

Make sure the port is open through the path from the development environment to the hosting server, for example if you are using EC2, add the port to the Inbound Rules of the Security Group.

5. Create New Publish Profile in Visual Studio

  1. Open the project you want to publish, then create a new publish profile.
  2. Select Web Server (IIS) -> Web Deploy.
  3. Write the server details as follow:
    • Server: https://(ip or name):8172/msdeploy.axd
    • Site name: site/application as in IIS
    • Username and Password are windows credentials.
  4. Click Finish.
  5. You might need to add <AllowUntrustedCertificate>True</AllowUntrustedCertificate> to the publish profile found under solution tree: YourProject -> Properties -> PublishProfiles.

Publish Profile

6. Publish Your Project

We finished setting up Web Deploy, now you just need to click publish, and Web Deploy will do all the work for you.

See Also

Web Deploy with command line

Top comments (0)