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.
- IIS 7
- Visual Studio 2010
Note: The order of steps is important.
1. Install Web Management Service (WMSVC)
- In remote server, open Control Panel -> Turn Windows features on or off.
- Look for Internet Information Services (IIS) -> Management Tools -> check Management Service.
- Proceed to install.
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.
3. Get Web Deploy
- Open WebPI directly (start menu for example), not through IIS Manager.
- Search for Web Deploy, then install.
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
- Open the project you want to publish, then create a new publish profile.
- Select Web Server (IIS) -> Web Deploy.
- Write the server details as follow:
https://(ip or name):8172/msdeploy.axd
- Site name:
site/applicationas in IIS
- Username and Password are windows credentials.
- Click Finish.
- You might need to add
<AllowUntrustedCertificate>True</AllowUntrustedCertificate>to the publish profile found under solution tree: YourProject -> Properties -> PublishProfiles.
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.
Top comments (0)