Deploy an ASP.NET site through Web Deploy using Publish in Visual Studio

This post goes through the steps necessary to enable remote deployment to a web server from within Visual Studio using the Publish command.

  • 22 August 2011
  • 0


This post is based on a developer machine running Visual Studio 2010.

The target machine, ie the web server we want to publish our website to, is running Windows Server 2008 with IIS 7.5.

Install Web Deploy on the server

Install the Web Deploy tool on the target server. Note that I wasn’t able to do it through Web Platform Installer since that wouldn’t add the Management Service Delegation icon to IIS Manager. Instead I downloaded the MSI and ensured the IIS 7 Deployment Handler (including its sub-features) were installed:

Screenshot of Web Deploy setup wizard

Configure the Management Service

After installing Web Deploy, if you select the server node in IIS Manager on the target server…

Screenshot of IIS Manager

…you should see a Management Service and a Management Service Delegation icon:

Screenshot of Management Service Delegation and Management Service icons in IIS Manager

Double-click the Management Service Delegation icon and ensure the Allow administrators to bypass rules option is selected:

Screenshot of dialog to set the Allow administrators to bygpass rules option in IIS

Next, double-click the Management Service icon to set up remote access:

Screenshot of Management Service dialog for remote access to IIS

Next, click Start to ensure the Management Service is running:

Screenshot of option to start the Management Service

You should see two separate services, Web Deployment Agent Service and Web Management Service, running on the target machine:


Set up a local administrator account on the target machine

In my case the target machine wasn’t on the same domain as the developer machine, so I set up a local account with administrator privileges on the target machine:

Screenshot of local administrator account setup

Publish from Visual Studio 2010

To publish our website to the target server we right-click the project node in Solution Explorer in Visual Studio and click Publish:

Screenshot of Publish command in Visual Studio

Enter the target machine’s URL in the Service URL textbox (note that the HTTPS protocol is used, you’ll get a 404 error if you try to use HTTP).

Enter the target website’s name in the Site/application textbox (this is the friendly name of the site, ie the name that is displayed in the IIS Manager node tree).

Unless you have a signed certificate on the target machine you need to check the Allow untrusted certificate checkbox.

Finally, enter the username and password of the local administrator account.

Screenshot of Publish Web dialog in Visual Studio

Finally, click Publish to publish your project to the target machine.

You can see the actions performed by, and result of, the publish by looking in the Output pane in Visual Studio:

Screenshot of Visual Studio Output pane after publish command

Missing the Management Service icons

If you’re missing the Management Service or Management Service Delegation icons in IIS Manager you might be missing the Management Service feature.

Go to Server Manager, expand the Roles node and then right-click Web Server (IIS):

Add Role Services to IIS

Next, make sure the Management Service option under Management Tools is selected:

Installing the IIS Management Service

Note that this has to be done before installing Web Deploy, otherwise some features will be missing when running the Web Deploy installer.