Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS2010 When debugging web.config transforms are not being applied. Building a deployment package works

When I debug a web application, the web.config transforms are not applied. I simply find that the configuration in web.config is not applying the transform for the configuration I'm currently using.

Yet if I build a deployment package then I find that the web.config does have the current transforms applied.

Are transforms not applied when debugging? I'm starting to wonder if this is the case, but I have coworkers insisting that it works for them.

like image 531
Mark Henderson Avatar asked Jun 09 '11 22:06

Mark Henderson


People also ask

How does web config transform work?

A Web. config transformation file contains XML markup that specifies how to change the Web. config file when it is deployed. You can specify different changes for specific build configurations and for specific publish profiles.

How do I create a new transformation in web config?

If you have a web application project, Right-click on web. config and choose Add Config Transform. This will add any config transforms that are missing from your project based on build configurations (i.e. if you have Production and Staging build configs, both will get a transform added).


2 Answers

Web.config transforms are only applied when publishing or deploying.

Jared Harding provided a link where a member of the .NET Team answered this question in the response here: VS2010 Clean Web.configs - not updating

The link he provided for ease of reference is: http://forums.asp.net/p/1532038/3711423.aspx

like image 106
Felan Avatar answered Oct 01 '22 22:10

Felan


You can start a transform by introducing a "AfterBuild" entry in your project file as described here. Downside: you have 2 web.config files...

http://kfigy.blogspot.ch/2010/03/making-visual-studio-2010-webconfig.html

like image 37
Peter Gfader Avatar answered Oct 01 '22 22:10

Peter Gfader