How to: Disable Web.config Transformation
Web.config files typically include settings that have to be different depending on which environment the application is running in. For example, your development Web.config file might enable debugging, but you might not want debugging enabled in production. You can create transform files that automate changes that are applied to Web.config files during deployment. For more information, see How to: Transform Web.config When Deploying a Web Application Project.
If a transform file exists for a build configuration, and when you deploy by using that build configuration, the changes in the transform file are applied automatically to the deployed Web.config file. However, you might not want the transforms to be applied during a specific deployment. For example, suppose your development Web.config file enables debugging and your transform file disables it on the destination server. When a problem arises that requires debugging on the destination server, you might want to disable that specific transformation, deploy the project, debug the problem, reenable the transform, and then redeploy the project.
If you do not want transforms to be applied for a build configuration, you can use one of the following methods:
Comment out specific transforms in the transform file. In most scenarios, this will be the appropriate method to use, because you typically want the remaining transformations to apply. For example, even if you want to temporarily remove a transformation that disables debugging, you probably still want to run the transformation that modifies the database connection string.
Rename the transform file for the build configuration to a name that does not correspond to a defined build configuration. For example, you might change Web.Debug.config to Web.Debugx.config. (Renaming has to be done outside of Visual Studio. You cannot rename these files in the Solution Explorer window.)
Delete the transform file for the build configuration (the one that is named Web.configurationname.config). If you have customized the file, the customizations will be lost.
Edit the project file to specify that transforms should not be applied. If you use this method, you can also disable the automatic transformation of a connection string that occurs when you specify the "-Web.config Connection String" suffix for the name of an entry in the Database Entries grid on the Package/Publish Web tab of the project Properties page. (For information about how to specify automatic transformation of a connection string during deployment, see the entry for Connection string for destination database in Package/Publish SQL Tab, Project Properties.)
This following procedure explains the last of these options — how to edit the project file.
Editing the Project File
To disable transforms for a build configuration, you add an TransformWebConfigEnabled element to the project file and set its value to False.
To edit the project file
Open the project's .project file (the file that has the .csproj or .vbproj extension) in a text editor.
If the project is in a solution that has multiple projects, you can right click the project name in Solution Explorer and select Unload Project, then right-click the project and select Edit. If the project is not in a solution, use Windows Explorer to navigate to the project directory, and then open the .csproj or .vbproj file by using Notepad or another text editor. (You can find the path to the project file in the Project Folder field of the Properties window.)
Find the PropertyGroup element that pertains to the build configuration that you are entering settings for.
For example, if you are creating settings for the Debug build configuration, look for the PropertyGroup element that has the following opening tag:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
Within this element, add TransformWebConfigEnabled and AutoParameterizationWebConfigConnectionStrings elements, as shown in the following example:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <TransformWebConfigEnabled>False</TransformWebConfigEnabled> <AutoParameterizationWebConfigConnectionStrings> False </AutoParameterizationWebConfigConnectionStrings> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup>
Save the changes and close the project file.
If you edited the project file by unloading the project, in Solution Explorer right-click the project and select Reload Project.