(Transform Web.config) Setup multiple configuration files when developing application for different environments

This article provide you help while developing application for different environments. Like if you want to separate config file for staging and another for live and another for QA. You can use Transform Web.config method in visual studio to accomplish multiple configuration file in single project.

Transform Web.config

This feature does however require you to have the VS2012 Update 2 or the Azure SDK 2.0 for VS2010. In Visual Studio, navigate to the Solution Configuration drop down list and choose "Configuration Manager".

multiple configuration file in single project

Next, look for the Active solution configuration drop down and select "New". multiple configuration file in single project

Give your configuration a name - I am going to call mine "Staging". I am also going to copy the settings from another transform. multiple configuration file in single project

Finally, right-click on Web.Config file and choose "Add Config Transform". multiple configuration file in single project

Once complete, you should notice your new Web.Config transform.
multiple configuration file in single project

That's it! Next time you deploy simply choose the appropriate solution configuration and your settings will be applied.

USING THE PUBXML FILE

You can also achieve the same result by using a publish profile file (.pubxml). Start by navigating to your web project in the Solution Explorer and choosing "Add Config Transform". This will add a new config transform for that publish profile only. multiple configuration file in single project

Once complete, you should notice that the appropriate Web.Config transform has been created. multiple configuration file in single project

When you deploy your next project, simply select the solution configuration that you need from the Solution Configuration drop down and the settings in your Web.Config file will be applied.