Pubxml XML to change web.config value during web deployment

Suppose I have a web.config parameter in the <appSettings><add key="myParam" value="myValue"/></appSettings> , and I want to change the value for myParam depending on the publishing profile used, i.e. DEVELOPMENT.pubxml and TEST.pubxml for website deployment.

What is the easiest way to do this? How to specify in pubxml which keys I want to convert, where are they, etc.?

You can also appreciate a direct answer or a link to a resource that answers this question.

+4
source share
1 answer

You can create Web.config conversion files for publishing profiles, as well as for creating configurations. When publishing to Visual Studio or from the command line, Visual Studio applies both the appropriate assembly configuration conversion and the publication profile transformation. 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 go through examples of creating publishing profile transformations and examples from the command line.

The tutorials use a web application project. If when you deploy a website, you mean deploying a website project, the process is basically the same until you installed the latest VS update (see the first tutorial in the series for links to VS updates).

+5
source

Source: https://habr.com/ru/post/1480625/


All Articles