Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web.config appSettings configSource attribute transformation

I am trying to update the configSource attribute on the appSettings element within my web.config file using web.config transformations.

I have the following in my web.config

    <appSettings configSource="Config\appSettings.local.config">
    </appSettings>

I want this to be

    <appSettings configSource="Config\appSettings.prod.config">
    </appSettings>  

when i build Release. This is not happening. I have the following in my Web.Release.config in the element

    <appSettings xdt:Transform="SetAttributes(configSource)" configSource="Config\appSettings.prod.config" />
like image 389
user1252399 Avatar asked Mar 06 '12 14:03

user1252399


2 Answers

Transformations only happen when you deploy the web application (or create a deployment package). It does not happen when you simply build the solution.

http://msdn.microsoft.com/en-us/library/dd465326.aspx

"For Web application projects, ASP.NET provides tools that automate the process of changing (transforming) Web.config files when they are deployed."

like image 182
Andre Loker Avatar answered Sep 28 '22 03:09

Andre Loker


You can cause the transformation to happen on build if you like though, with a little poking around in your project file. I wrote a post on this a while back, its centered on app.config but it will work for web.config you can just miss a few steps out!

http://www.chrissurfleet.co.uk/post/2011/07/27/Faking-Webconfig-transformations-in-appConfig.aspx

like image 30
Chris Surfleet Avatar answered Sep 28 '22 03:09

Chris Surfleet