Walkthrough: Deploying a Web Application Project Using a Web Deployment Package (Part 4 of 4)

This is the fourth in a series of walkthroughs that illustrate how to deploy a Web application project by using a Web deployment package. For more information about the series, see Walkthrough: Deploying a Web Application Project Using a Web Deployment Package (Part 1 of 4).

In this walkthrough you use the package that you created in the third walkthrough in order to install the Web application on a remote computer. This walkthrough illustrates the following tasks:

  • Installing a package on a remote computer by using the deploy.cmd file.

  • Using custom deployment parameters for configuration values that you want to be able to change when the package is installed.

Prerequisites

For a list of prerequisites, see Walkthrough: Deploying a Web Application Project Using a Web Deployment Package (Part 1 of 4).

Preparing the Destination Server

If someone else is setting up the destination server for you, whoever is doing that will specify which deployment method you must use. If you are setting up the destination server, you must select a method. The methods that are available are as follows:

  • The Web Management Service (WMSvc) and the Web Deployment handler.

  • The Web Deployment Agent Service (MsDepSvc).

  • The Web Deploy tempAgent provider setting.

For more information about these methods, or for information about how to set up a destination server to use one of them, see How to: Install a Deployment Package Using the deploy.cmd File.

In addition to being configured for the deployment method that you select, the destination server must have the following:

  • IIS 7 enabled.

  • ASP.NET 4 registered with IIS 7.

  • An ASP.NET 4 application pool that is assigned to the Default Web Site.

The destination server should be set up before you continue with this walkthrough.

Setting Deployment Parameters

In the following procedure, you make sure that the SetParameters.xml file contains the correct values. This is equivalent to verifying or changing parameter values that are displayed in the Enter Application Package Information dialog box when you install a package by using IIS Manager.

To modify the SetParamters.xml file

  1. Open the Web application project that you created in the first walkthrough in this series.

  2. In Solution Explorer, expand the obj folder, expand the Release folder, and then expand the Package folder. (In a previous walkthrough you opened the Debug folder. Make sure that you are working with the Release folder this time and are not working with the Debug folder.)

  3. Open AdventureWorks.SetParameters.xml.

    The XML in the file resembles the following example:

    <parameters>
      <setParameter name="IIS Web Application Name" 
        value="Default Web Site/AdventureWorks" /> 
      <setParameter name="machineKey" value="staging" /> 
      <setParameter name="ApplicationServices-Deployment Connection String"
        value="... " /> 
      <setParameter name="AWLTConnectionString-Deployment Connection String"
        value="..." /> 
      <setParameter name="ApplicationServices-Web.config Connection String" 
        value="..." /> 
      <setParameter name="AWLTConnectionString-Web.config Connection String" 
        value="..." /> 
    </parameters>
    

    Notice the setParameter element that has machineKey as the value of its name attribute. The value attribute of this setParameter element is staging, which is the default value that you set in the third walkthrough in this series for deploying to a staging server. If you were preparing to install the package on a production server, you could change the value attribute of this setParameter element for the machineKey parameter to a production value. The deployed Web.config file would then be updated to contain the production value instead of the staging value.

Preparing to Install Remotely by Using the Deploy.cmd File

In the following procedure, you prepare to run the deploy.cmd file by opening a command prompt and browsing to the folder that contains the deploy.cmd file.

To prepare to install remotely by using the Deploy.cmd file

  1. In Solution Explorer, select the AdventureWorks.SetParameters.xml file.

  2. In the Properties window, note the value of the Full Path property.

  3. In the Windows Start menu, click Command Prompt.

  4. Browse to the folder that contains the AdventureWorks.SetParameters.xml file.

    The Command Prompt window is now ready for you to enter the command that runs the deploy.cmd file.

The syntax for the deploy.cmd file varies depending on the deployment method that you are using. Use the procedure that is for the method that you have chosen.

The syntax examples in the following sections include the following placeholders:

  • ServerName. Replace this with the name of the destination server.

  • UserName and Password. If applicable, replace these with the actual credentials that have been set up for deployment.

Installing Remotely by Using the Web Deployment Handler

The following procedure describes how to install the package by using the Web Management service (WMSvc) and the Web Deployment handler.

To deploy by using the Web Management service and the Web Deployment handler

  1. Enter the following command to execute a trial run of package installation:

    AdventureWorks.deploy.cmd /t /m:https://ServerName:8172/MSDeploy.axd /u:username /p:password /a:basic
    

    For Web Management service deployment, you are typically given a user account to use for deployment.

    The t option runs the command in trial mode so that you can examine the results of the command before you actually deploy the application.

    Note

    For certain scenarios, deployment might fail when you use the t option although it succeeds when you use the y option. For more information, see ASP.NET Web Application Project Deployment FAQ.)

  2. If the output from the trial run is not what you expect, make whatever changes are necessary.

  3. When the output from the trial run is what you expect, repeat the command, replacing the t (trial) flag with a y (yes) flag, as shown in the following example:

    AdventureWorks.deploy.cmd /y /m:https://ServerName:8172/MSDeploy.axd /u:username /p:password /a:basic
    

Installing Remotely by Using the Web Deployment Agent Service

The following procedure describes how to install the package by using the Web Deployment Agent service (MsDepSvc).

To deploy by using the Web Deployment Agent service

  1. Enter the following command to execute a trial run of package installation:

    AdventureWorks.deploy.cmd /t /m:ServerName
    

    For Web Deployment Agent service, you typically use Windows authentication and do not specify a user name and password.

    The t option runs the command in trial mode so that you can examine the results of the command before you actually deploy the application.

    Note

    For certain scenarios, deployment might fail when you use the t option although it succeeds when you use the y option. For more information, see ASP.NET Web Application Project Deployment FAQ.)

  2. If the output from the trial run is not what you expect, make whatever changes are necessary.

  3. When the output from the trial run is what you expect, repeat the command, replacing the t (trial) flag with a y (yes) flag, as shown in the following example:

    AdventureWorks.deploy.cmd /y /m:ServerName
    

Installing Remotely by Using the tempAgent Provider Setting

The following procedure describes how to install the package by using the Web Deploy tempAgent provider setting.

To deploy by using the Web Deploy tempAgent provider setting

  1. Enter the following command to execute a trial run of package installation:

    AdventureWorks.deploy.cmd /t /m:ServerName /g:true
    

    For the tempAgent provider setting you typically use Windows authentication and do not specify a user name and password.

    The t option runs the command in trial mode so that you can examine the results of the command before you actually deploy the application.

    Note

    For certain scenarios, deployment might fail when you use the t option although it succeeds when you use the y option. For more information, see ASP.NET Web Application Project Deployment FAQ.)

  2. If the output from the trial run is not what you expect, make whatever changes are necessary.

  3. When the output from the trial run is what you expect, repeat the command, replacing the t (trial) flag with a y (yes) flag, as shown in the following example:

    AdventureWorks.deploy.cmd /y /m:ServerName /g:true
    

Next Steps

In the first two walkthroughs in this series you deployed a file system Web application project to an IIS Web application for testing on the development computer. In the third walkthrough you created a package to use for deploying to a staging server or to a production server. In this walkthrough, which is the last in the series, you deployed the package to a remote computer by using the deploy.cmd file that Visual Studio generates when it creates the package.

Some other typical scenarios for deployment to staging and production servers include the following:

  • Use the same package for deployment to multiple servers in a Web farm, suppressing database deployment for each installation after the first installation.

  • Prevent certain files (for example, Web.config files) from being deployed because they are manually updated on the destination server and you do not want to overwrite those changes.

  • For information about how to handle these scenarios, see How to: Install a Deployment Package Using the deploy.cmd File.

See Also

Concepts

ASP.NET Deployment Content Map