Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

web.config file reverting to previous after build?

I'm having a puzzling problem with my web.config file on Visual Studio 2015. I open the project, open the web.config file and update a connection string to point to a different database source. I save the change and then close the web.config file. If I open back up the web.config file, the updates that I made are still there. But after I do a build, if I open the web.config file my update has reverted to what was there previously. Any ideas why?

like image 634
PixelPaul Avatar asked Oct 06 '16 15:10

PixelPaul


1 Answers

I had the same issue. Turns out there was a modification to the default setup in my .csproj file...

<Target Name="BeforeBuild">
    <TransformXml Source="Web.Template.config" Transform="Web.$(Configuration).config" Destination="Web.config" />
</Target>

This generates the web.config file at Build time based on Web.debug.config, Web.release.config, etc.

As described in this article: http://www.kongsli.net/2012/01/13/enabling-web-transforms-when-debugging-asp-net-apps/

like image 183
Mike W Avatar answered Nov 16 '22 16:11

Mike W