5

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.

4

1 回答 1

5

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).

于 2013-05-14T16:37:59.830 回答