How to: Edit Deployment Settings in Publish Profile (.pubxml) Files and the .wpp.targets File in Visual Studio Web Projects

This topic explains how to configure deployment settings by editing publish profile (.pubxml) files or by creating a .wpp.targets file for Visual Studio web projects.

Note

This topic applies to Visual Studio 2012 and Visual Studio Express 2012 for Web. The topic covers features that are included in the latest Visual Studio Web Publish Update available as of June, 2013. Most of these features are also available in Visual Studio 2010 and Visual Web Developer 2010 Express when you install the Web Publish Update.

Editing a publish profile file or creating a .wpp.targets file might be necessary because some deployment configuration tasks can't be done in the Visual Studio UI. Some deployment options can only be specified by editing one of the XML files that control the Web Publishing Pipeline (WPP).

This topic includes the following sections:

  • Editing Publish Profile (.pubxml) Files

    When you want to configure settings that are specific to a particular publish profile, you edit the publish profile file. Publish profile files are named <profilename>.pubxml and are located in the PublishProfiles folder. The PublishProfiles folder is under Properties in a C# web application project, under My Project in a VB web application project, or under App_Data in a web site project. Each .pubxml file contains settings that apply to one publish profile. The values you enter in the Publish Web wizard are stored in these files.

  • Creating a .wpp.targets File

    When you want to configure settings that apply to all profiles you use in a project, you create a .wpp.targets file. The .wpp.targets file must be located in the project folder and must be named <projectname>.wpp.targets.

Note

If you use the Package/Publish SQL tab to configure database deployment, you might have to edit database deployment settings in the project file. For information about how to edit settings that are related to the Package/Publish SQL tab, see the .NET Framework 4 version of this topic.

Editing Publish Profile (.pubxml) Files

When you create a publish profile, two files are created in the PublishProfiles folder: <profilename>.pubxml and <profilename>.pubxml.user. The .pubxml.user file contains only a few settings that apply to a specific user, such as an encrypted password. By default it is not included in source control. Typically when you change settings related to a profile you edit the .pubxml file rather than the .pubxml.user file.

To edit a publish profile (.pubxml) file

  1. In Solution Explorer, double-click the file to open it.

  2. If the element you want to change is already in the PropertyGroup element, change its value; otherwise add the element to the PropertyGroup element.

    For example, suppose that you want to disable the default setACL behavior of Visual Studio deployment. By default, Visual Studio sets read permissions on the root folder of the destination site and write permissions on the App_Data folder. If you know that the default permissions on folders are correct and don't need to be set, you can disable this behavior for a specific publish profile by adding the following XML to the publish profile file:

    <IncludeSetACLProviderOnDestination>False</IncludeSetACLProviderOnDestination>
    

    When you open the publish profile file, it resembles this example:

    <Project ToolsVersion="4.0" xmlns="https://schemas.microsoft.com/developer/msbuild/2003">
      <PropertyGroup>
        <WebPublishMethod>Package</WebPublishMethod>
        <LaunchASiteUrlAfterPublish>False</LaunchASiteUrlAfterPublish>
        <SiteUrlToLaunchAfterPublish />
        <MSDeployServiceURL />
        <DeployIisAppPath />
        <RemoteSitePhysicalPath />
        <AllowUntrustedCertificate>False</AllowUntrustedCertificate>
        <SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
        <DeployAsIisApp>True</DeployAsIisApp>
        <MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
        <UserName />
        <SavePWD>True</SavePWD>
        <PublishDatabaseSettings>
          <!— this section omitted to keep the example short -->
        </PublishDatabaseSettings>
      </PropertyGroup>
    </Project>
    

    To disable the default setACL behavior, add the IncludeSetACLProviderOnDestination element, as shown in this example, where it appears immediately after the opening PropertyGroup tag:

    <Project ToolsVersion="4.0" xmlns="https://schemas.microsoft.com/developer/msbuild/2003">
      <PropertyGroup>
        <IncludeSetACLProviderOnDestination>False</IncludeSetACLProviderOnDestination>
        <WebPublishMethod>Package</WebPublishMethod>
        <LaunchASiteUrlAfterPublish>False</LaunchASiteUrlAfterPublish>
        <SiteUrlToLaunchAfterPublish />
        <MSDeployServiceURL />
        <DeployIisAppPath />
        <RemoteSitePhysicalPath />
        <AllowUntrustedCertificate>False</AllowUntrustedCertificate>
        <SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
        <DeployAsIisApp>True</DeployAsIisApp>
        <MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
        <UserName />
        <SavePWD>True</SavePWD>
        <PublishDatabaseSettings>
          <!— this section omitted to keep the example short -->
        </PublishDatabaseSettings>
      </PropertyGroup>
    </Project>
    
  3. Save the file.

Avoid editing database-related settings in the .pubxml file, because Visual Studio changes these automatically as it finds changes in the project. Database-related settings include the following:

  • The PublishDatabaseSettings element. (This element might appear in the PropertyGroup element.)

  • Any ItemGroup elements that appear after the PropertyGroup element.

Creating a .wpp.targets File

Settings that you configure in the .wpp.targets file apply to all publish profiles. The following procedure explains how to create a .wpp.targets file.

To create a .wpp.targets file

  1. Create a new XML file in the project folder (the same folder that holds the .csproj or .vbproj file) and name it <projectname>.wpp.targets.

  2. Create a Project element as the top-level element, and within it create a PropertyGroup element.

  3. Add the settings that you want to specify for all publish profiles. For example, if you want to disable the default setACL behavior, add the IncludeSetACLProviderOnDestination element, as shown in this example:

    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="4.0" xmlns="https://schemas.microsoft.com/developer/msbuild/2003">
      <PropertyGroup>
        <IncludeSetACLProviderOnDestination>False</IncludeSetACLProviderOnDestination>
      </PropertyGroup>
    </Project>
    
  4. Save and close the file.

  5. Close Visual Studio and reopen it.

    Because Visual Studio caches .targets files, changes made to one of them might not be effective until the next time Visual Studio is opened.

You can also use the .wpp.targets file to extend the web publishing pipeline in more complex ways. For example, you might want to keep the default setACL behavior but automate the setting of write permissions on another folder in addition to App_Data. For an explanation of how to do that, see Setting Folder Permissions on Web Publish on Sayed Hashimi's blog.

See Also

Concepts

Web Deployment Overview for Visual Studio and ASP.NET

Other Resources

Web Deployment Content Map for Visual Studio and ASP.NET