Export (0) Print
Expand All

How to: Deploy a Web Application Project Using One-Click Publish and Web Deploy

This topic explains how to deploy a Web application project by using one-click publish and the Web Deploy publish method. One-click publish with the Web Deploy publish method enables you to automate most tasks that are required in order to deploy a Web application.

To use these features, Web Deploy must be installed on your development computer and the same version of Web Deploy must be installed on the destination Web server. (By default, Web Deploy is installed on the development computer when you install Visual Studio.) If you are deploying to a third-party hosting company, the company must support the version of ASP.NET that your Web application targets and must support one-click publish. For information about how to use one-click publish with other publish methods, see How to: Deploy a Web Application Project Using One-Click Publish Without Web Deploy.

NoteNote

Web deployment tools have been improved in Visual Studio 2012. You can install the improved tools in Visual Studio 2010 and Visual Web Developer 2010 Express by installing the Visual Studio Web Publish Update. For information about how to use the new tools, see the documentation for Visual Studio 2012. A good place to start is Web Application Project Deployment Overview for Visual Studio and ASP.NET.

Deploying a Web application project using one-click publish might involve the following additional tasks that are not described in this procedure:

  • Specifying database deployment options. If the Web project that you want to deploy uses a database, and if scripts must run during deployment in order to set up database structures or data in the destination environment, you must enter settings in the Package/Publish SQL tab of the project Properties page. For more information, see How to: Deploy a Database With a Web Application Project.

  • Specifying Web.config file transformations. Web.config files typically include settings that have to be different depending on which environment the application is running in. For example, the Web.config file on your development computer might enable debugging, but you typically do not want debugging enabled for an application that runs on a production server. You can create transform files that automate the process of changing Web.config settings during deployment. For more information, see How to: Transform Web.config When Deploying a Web Application Project.

For more information about Web application project deployment, see ASP.NET Deployment Content Map.

You use the Package/Publish Web tab of the project Properties page to configure settings that determine what files should be included when the Web application is deployed. The default settings on this tab will work for many typical scenarios. You can skip this procedure if all the following conditions are true:

  • You want to deploy only the files that are required in order to run the site. For example, this might be true if source code files are compiled into assemblies, and you want to copy only the assemblies to the destination server.

  • You do not have to replicate IIS settings from the source computer to the destination server. For example, this might be true if the project to deploy is a local IIS Web project and you have set up error-handling rules for its IIS application, but you do not have to replicate those rules on the destination server. If the project to deploy is a file system Web project, there are no IIS settings to replicate.

To specify files and settings to deploy

  1. In Solution Explorer, right-click the project name and then click Properties.

  2. Click the Package/Publish Web tab.

    The Package/Publish Web tab is displayed, as shown in the following illustration:

    Package/Publish dialog box
  3. In the Configuration list, select the build configuration that you want to configure deployment settings for.

    You can configure deployment for the Debug orRelease build configurations, or fora custom build configuration that you have created by using the Configuration Manager dialog box. For example, you might want different settings for deploying to a test server and for deploying to a production server.

    The default value for the Configuration is Active, which means that the settings on this tab apply to the build configuration that is currently selected for the project. The currently selected build configuration is shown in the main toolbar and in the Configuration Manager dialog box. (To open Configuration Manager, select it from the Build menu.)

  4. Select one of the following options from the Items to deploy (applies to all deployment methods) drop-down list:

    • Only files needed to run this application. Files that are not required in order to run the site are not deployed to the destination server, such as code files that are compiled into assemblies.

    • All files in this project. All files included in the project are deployed to the destination server. Files that are in the project folder but are not included in the project are excluded.

    • All files in this project folder. All files in the project folder are deployed to the destination server, even if they are excluded from the project.

    For more information about how Visual Studio determines which files to deploy, see the question "Why don't all of the files in my project folder get deployed?" in ASP.NET Web Application Project Deployment FAQ.

  5. If you expect that you will never want to enable debugging on the destination server, select the Exclude generated debug symbols check box.

    Clearing this option causes .pdb files to be deployed to the destination server. These files are required for debugging. You typically do not want .pdb files on a production server, but you might want them on a test server.

  6. If you have files in the App_Data folder and you do not want them to be deployed to the destination server, select the Exclude files from the App_Data folder check box.

    For example, you might have a SQL Server Express .mdf file in the App_Data folder during development. However, you plan to deploy the database by using automatically generated scripts on the production server. In that case, you would select this option when you deploy to the production server because there is no use for the .mdf file on the production server.

  7. If you want to run database scripts that are specified in the Package/Publish SQL tab during deployment, select the Include all databases configured in Package/Publish SQL tab check box. (The Package/Publish SQL tab is described in a procedure later in this topic.)

    A typical scenario is to run scripts that configure databases only the first time a Web application is deployed. When you deploy updates to a Web application, you typically do not have to deploy updates to the database.

  8. If the Web project that you are deploying is an IIS Web project, and if you want to propagate the project's IIS settings to the destination environment, select the Include all IIS settings as configured in IIS Manager check box.

    IIS settings specify options such as authentication methods and how the Web application responds to errors. If you are deploying to a server on your company's network, you might want to configure the destination server the same as the development server when you deploy to a test server, but not when you deploy to a production server. If you are deploying to a hosting company, the account that you use for deployment typically will not have the administrative permissions that are required in order to make changes to IIS settings. In that case, do not select this option.

    If the current Web project is not an IIS Web project, this option and the option for application pool settings are disabled.

    NoteNote

    Inherited IIS settings are not propagated to the destination server. For example, suppose that the IIS Web application that you want to deploy is under the default Web site on the source server, and the default Web site has Windows authentication set to true. If you deploy this site to the default Web site on a server that has Windows authentication set to false for the default Web site, Windows authentication will be false for the deployed Web site. This is true even if you select the Include all IIS settings as configured in IIS Manager check box. In that case, you will have to configure the settings manually on the destination server.

  9. If you selected the Include all IIS settings as configured in IIS Manager option, and if you want application pool settings from the Web project to be duplicated in the destination environment, select the Include application pool settings used by this Web project check box.

Before you can publish the Web application, you must create a publish profile that specifies how to publish. You can create multiple profiles that have different settings. (There is a limit of 50 profiles.) Before you click the Publish button, you can select the profile that has the settings that you want to use. The publish profile settings apply to the active build configuration (for example, Debug or Release). The following procedure explains how to create a profile.

To create a publish profile

  1. In the Build menu, click Publish projectname.

    The Publish Web dialog box is displayed.

    Publish Profile dialog box
  2. In the Publish profile box, enter a name for the new profile.

  3. In the Publish method drop-down list, select Web Deploy.

    For information about how to use one of the other methods (FTP, File system, or FPSE), see How to: Deploy a Web Application Project Using One-Click Publish Without Web Deploy.

  4. Enter a value for Service URL.

    If you are publishing to the development computer (that is, to your computer), enter localhost or the name of your computer. You must have administrative rights on your computer.

    If you are publishing to a server on your company's network, enter one of the following URLs:

    http://ServerName

    http://ServerName/msdeployagentservice

    The destination server must be set up for the Web Deployment Agent Service (MSDepSvc, also known as Remote Agent service), and you must have administrative rights on the destination server. For information about how to set up the destination server, see Web Deploy Remote Service on the Microsoft TechNet Web site.

    If you are publishing to a hosting company, the required value will be provided by the company. The value can be entered in one of the following formats:

    • https://HostingCompanyURL:8172/msdeploy.axd (for example, https://contoso.com:8172/msdeploy.axd)

    • https://HostingCompanyURL (for example, https://contoso.com)

    • HostingCompanyURL (for example, contoso.com)

    The hosting company must set up the destination server for the Web Management service (WMSvc, also known as Web Management Service, which is used with the Web Deployment Handler). For information about how to set up the destination server, see Configuring the Web Deployment Handler on the Microsoft TechNet Web site. This method is typically used by hosting companies, but it can also be used on your internal company network. If you use this method, you do not have to have administrative rights on the destination server.

  5. Enter a value for Site/application.

    If you are publishing to the development computer or to a server on your company's network, enter the site and application name as they appear in IIS Manager. For example, if you are publishing to the default Web site and if the application name is MyApplication, enter Default Web Site/MyApplication.

    If you are publishing to a hosting company, the required value will be provided by the company. The value will typically be either a domain name (for example, contoso.com) or a domain and application name (for example, contoso.com/MyApplication).

  6. If you are not deploying IIS settings, select the Mark as IIS application on destination check box.

    This option is not shown if you are deploying IIS settings, because the Web project's IIS application status is one of the IIS settings that is deployed.

    You typically select this check box when the Include all IIS settings as configured in IIS Manager check box on the Package/Publish Web tab of the project Properties page is cleared. There are very few scenarios in which you would not want to deploy a Web project as an IIS application on the destination Web server. For example, suppose that the project that you are deploying is not actually a Web application but only contains virtual directory content, such as images, XML files, and so forth. In that case, you might want to clear this check box so that the deployed project is not set up as an IIS application.

  7. If you want one-click publish to delete files on the destination server that have no matching files in the Web project, clear the Leave extra files on destination check box.

    The publish process deletes files on the destination server under the following circumstances:

    • You clear the Leave extra files on destination option.

    • The files already exist on the destination server in the publish location or in any subfolders.

    • The same files do not exist in the same folders in the Web application project.

    NoteNote

    If you clear the Leave extra files on destination check box, and if you have a Web application in a subfolder when you deploy a project to the root folder, the subfolder will be deleted. For example, suppose that one project is for your main site at contoso.com and another project is for a blog at contoso.com/blog. The blog application is in a subfolder. If you clear the Leave extra files on destination check box, the blog application will be deleted when you deploy the main project.

  8. If you are publishing to a hosting company and the hosting company advises you to allow untrusted certificates, select the Allow untrusted certificate check box.

    Security noteSecurity Note

    If you select this check box, make sure that you do not make any typographical errors in the Service URL box. Otherwise you could send your files to a malicious Web site that has a URL similar to the one that you are deploying to.

  9. In the User name and Password boxes, enter credentials for an account that has sufficient authority to perform deployment tasks on the destination Web server.

    If you are publishing to a hosting company, this information will be supplied by the hosting company.

  10. Click the Save button to save the profile.

One-click publish is designed to make it easy to deploy a Web application and to update the application after it has been deployed. After the initial deployment, when you click the Publish button, Visual Studio determines what has changed in the Web site and deploys only the changes to the destination server.

NoteNote

Before you publish the Web application, you might also have to specify database and Web.config transform options. For more information, see How to: Deploy a Database With a Web Application Project and How to: Transform Web.config When Deploying a Web Application Project.

To publish the Web application

  • In the Publish Web dialog box or in the Web One-Click Publish toolbar, click the Publish button.

    NoteNote

    If you do not see the Web One-Click Publish toolbar, right-click the main menu and select Web One-Click Publish.

    The first time that you click the Publish button, Visual Studio and Web Deploy perform all the tasks that are required in order to set up the Web project on the destination server. If you click the Publish button again, only changes are deployed. For example, suppose that your site has 100 Web pages and you add one Web page. When you click Publish again, only the new Web page is copied to the destination server.

    NoteNote

    Database changes are not deployed automatically. You typically have to change database settings after the first deployment in order to prevent database scripts from being run during subsequent deployments. For more information, see How to: Deploy a Database With a Web Application Project.

NoteNote

One-click publish is a complex process that integrates several technologies in order to automate a variety of deployment tasks. For information that might help you resolve errors, see ASP.NET Web Application Project Deployment Overview and ASP.NET Web Application Project Deployment FAQ.

Community Additions

Show:
© 2014 Microsoft