There's many ASP.NET developers using Visual Studio who need flexible options and would like a UI to manage deployment tasks. These developers tend to deploy web applications themselves and a few deployment scenarios that exist today where you'll see those developers deploying applications themselves:
- Small to mid-sized companies where the developer sees the application end to end, often a solo developer, however s/he might be on a small team.
- Individual consultants or small consultancies that need to deploy remotely, often using FTP or FTPS (secure FTP).
- Small to mid-sized teams that don't have automated deployment or CI in place and are in charge of their own application deployments.
The central theme is that all three types of teams are all responsible for their own application deployments. If you work in a dev shop similar to one of these, you'll find Visual Studio 2010's Web Deploy feature is quite handy and should meet most of your deployment needs out of the box. But it's also easily extensible to get those few unique deployment tasks you may have configured and ready to go.
Until now, the deployment process has been less than fluent and barely integrated with the VS IDE. Developers have a long checklist of things to copy, register, configure, etc... and often some things are forgotten. A common solution to this is to use build hooks and PowerShell scripts or good old fashioned batch files to help automate the process. But scripts can only go so far - especially when configuration files need modifications (e.g., web.config transformations). The Package/Publish web tool will assist you in automating the deployment process, and will fit the needs of most small shop developers.
Both ASP.NET Web Forms and ASP.NET MVC applications can be deployed using this tool.
Package/Publish Web tool settings
Visual Studio 2010 Web Deploy alleviates most of the manual aspects of application deployment by adding a few UI based configuration pages and context menu integrations in Solution Explorer. Upon opening the project's properties, navigate to the Package/Publish Web tab on the left to display deployment options on the right.
Let's explore the Package/Publish Web settings in depth...
Use the Build Configuration & Platform settings to set the configuration environment in which you want to deploy. The options available out of the box are Debug and Release and with other build configurations can be setup by the developer.
To choose the files you want to deploy you have three options:
- Only files needed to run the application
- All files in this project
- All files in this project folder
Check to exclude debug symbols and App_Data folder contents if warranted. As a rule of thumb, if deploying to a production machine you will likely want include only files needed to run the application and to exclude the debug symbols.
Next, choose whether or not to deploy SQL database and IIS settings. The database deployment configuration is located in the Package/Publish SQL tab. The IIS settings are for the applications that are setup as an ASP.NET Web Site using IIS only. If you're using ASP.NET Web Applications or the ASP.NET Development Server (Cassini), these IIS settings are unavailable. You're still able to deploy to IIS, this option is only meant to copy the developer's IIS settings to the target machine.
Lastly the settings to create the deployment package are needed. By default, a .zip file is created with the contents and metadata use during the deployment process, and you can change the path to it. You also need to enter the name of an existing IIS Web Site/Application name on the target IIS machine, regardless of whether you've developed locally using IIS or the ASP.NET Development Server. For first time deployments, you can run the Web Deploy tool through the IIS Management Console or by using Web Deploy (msdeploy.exe).
Finally, you can set the password to deploy encrypted IIS settings.
That's the entire set of deployment options for the ASP.NET side of things using the P/PW tool. If you want to install items from the registry, GAC or COM components you can extend the Web Publishing Pipeline. The Package/Publish Database tab that is located directly beneath the Package/Publish Web tab in the project's properties can be used to move & modify database schema and/or data as well as run custom .sql scripts during deployment.
Once you've chosen the deployment configuration that you want, it's now time to build the package and deploy!
Now...Build & Publish!
Use the Solution Explorer's context menu for the final two steps in the process.
1. Build: Choose to build your deployment package, which is created as a .zip file in the location specified in the package settings. Use the link generated n the Output window to view the package results, .zip file, path and deployment metadata. The .zip file is the deployable unit for this application, the other files can safely be ignored.
2. Publish: The publish option located in the context menu of Solution Explorer is what you use to start the deployment process (also available from the Project menu). A few options need to be filled in so the tool knows where to deploy to and what credentials are needed. These settings can be saved as a profile so that you don't need to keep filling out port numbers, URLs, IIS info & credentials:
Publish Profile - Saved profiles are listed in the Publish Profile dropdown box. Adding, renaming and deleting of profiles are options available to you.
Publish Method - Options are Web Deploy, FTP, File System and FPSE (oh yeah, those FrontPage Server Extensions again :) ). The options underneath the Publish Method dropdown change depending on the context, for Web Deploy you need to specify the Service URL and Site/Application name. Other choices available are whether IIS should be marked as an application and if the files created during the deployment process should stay on the target server.
Credentials - If credentials are needed on the target server they can be specified here as well.
Lastly, the clicking the Publish button will push the deployment package to the server, unpack, and configure it to the specs you've set in the options. You'll see that the output window logs the actions taken and notifies of a successful deployment. Alternatively, IIS itself can be opened and the tool can import the publish settings in the .zip file from there. If you're a fan of the command line, msdeploy.exe is the way to go.
Once you've published, you should be able to open the URL and browse the application.