Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pubxml XML to change a web.config value on web deployment

Suppose I have a web.config parameter under <appSettings><add key="myParam" value="myValue"/></appSettings> and I want to modify the value for myParam depending on the publish profile I use, ie DEVELOPMENT.pubxml and TEST.pubxml for a web site deployment.

What is the most straightforward way to accomplish this? How do I specify in the pubxml which keys I want to transform, where they are, etc?

Either a direct answer or a link to a resource that answers this question would be highly appreciated.

like image 412
tacos_tacos_tacos Avatar asked May 14 '13 04:05

tacos_tacos_tacos


1 Answers

You can create Web.config transform files for publish profiles as well as for build configurations. When you publish, either in Visual Studio or from the command line, Visual Studio applies both the appropriate build configuration transform and the publish profile transform. See this tutorial:

http://www.asp.net/web-forms/tutorials/deployment/visual-studio-web-deployment/web-config-transformations

This is one of a series of tutorials. Others in the series run through examples of creating publish profile transforms and examples of doing it from the command line.

The tutorials use a web application project. If by web site deployment you mean you're deploying a web site project, the process is basically the same as long as you have installed the latest VS update (see the first tutorial in the series for links to the VS update).

like image 58
tdykstra Avatar answered Oct 29 '22 15:10

tdykstra