Search code examples
c#visual-studioweb-config

Visual Studio - Web config transform remembers old attribute value


I'm posting this question because I've just spent 1 complete day searching for the answer that I didn't find anywhere.

The problem is that I have 3 environments for my application :

  • Dev
  • Qua
  • Prod

So I have created a web config for each environment in order to change the database source. And I have also created a deploy profile for each environment in order to specify their respective server.

To test if my differents web config work as expected, I tried to swap every database source/server : dev server with qua database, dev server with prod database and so on...

But, for each deploy, the server keep the related database source :

  • Dev server => Dev Database
  • Qua server => Qua Database
  • Prod server => Prod Database

However, I followed every doc I found and tried a lot of alternatives from https://learn.microsoft.com/en-us/previous-versions/aspnet/dd465326(v=vs.110)?redirectedfrom=MSDN, using SetAttributes, Replace, Remove/Insert... but nothing resolved my problem.


Solution

  • Don't name your profiles like their web.config. Visual Studio seems to apply the web.config with the same name as the profile after the web.config you specified and overrides it.

    enter image description here