"Publishing" a web application means preparing the application into a state from which it can be "deployed" to the web server. For me, this has always been two distinct processes, but Visual Studio has some publishing options that allow you to deploy to a web server as part of the publishing process.
You have 4 "publish methods" to choose from when you right click a web application project and select Publish. FTP, File System, Web Deploy, and Web Deploy Package.
File System
Here you are simply choosing a folder and when you click Publish, the files will be placed in this folder. You can then copy these files into the physical directory of the site.
FTP
Same idea as above except you are selecting a folder on another computer.
Web Deploy
This is also known as One-Click Publishing. You simply specify the server name and the site, and Visual Studio will deploy the site for you when you publish. Specify the Destination URL field if you want the default browser to open up with this address when publishing and deployment is complete. Keep in mind that the server you are deploying to must support Web Deploy. Here are the instructions to set up a web server to support Web Deploy:
- Download and install Web Deploy 3.5. (This assumes you are publishing using Visual Studio 2013). During installation, be sure to click Custom and choose to install all the features available.
- Open up IIS, and click the root server node in the tree view on the left.
- Select Management Service.
- The options will be grayed out if the Web Management Service is running. Stop the service, and be sure to check the "Enable remote connections" checkbox.
- In addition you may need to add your development machine's IP address to the box at the bottom.
- You might also need to open a firewall port (8172 by default), on the server.
Web Deploy Package
Same idea as Web Deploy except a package is created instead of Visual Studio deploying the application for you. A package is simply a zip file that contains the published application files that you would also see if you selected the File System option. However, the package can be imported using IIS with a nifty wizard.
Web deploy packages allow you to set some runtime parameters for the web.config file. If there is a value that the developer does not know at compile time (like a password), the administrator will be prompted for the value when he imports the web deploy package. Simply add a file called parameters.xml to the project directory in Visual Studio and put something like this in there:
<parameters>
<parameter name="Test Key 1 Entry"
description="Specifies what environment you are in."
defaultValue="Development" tags="">
<parameterEntry kind="XmlFile"
scope="\\Web.config$"
match="//appSettings/add[@key='TestKey1']/@value">
</parameterEntry>
</parameter>
</parameters>
The parameter node describes what it will look like in the IIS wizard when you import the package. The parameterEntry node describes how to update the file. The scope attribute defines the file to update, and the match attribute represents an XPath that selects the attribute and node to update.
A note on transforming web.config files
When you do know the web.config settings for various environments at compile time, you transform web.config files. Essentially this means modifying the web.config that gets published based on the build configuration. Instructions for doing this is beyond the scope of this post.