Search code examples
asp.netweb-deploymentweb.config-transform

web.config transform not executing on publish


I use web.config transforms all the time and when I make a new site/project, I often copy a previous site, rename the *.csproj and rename oldsite to newsite inside the csproj as necessary. I do this often, but for some reason one of my projects will not run its transforms on publish. I don't even know what to show you in this post, so I'll update the question as necessary based on what you want to see. Googling around I didn't find much. But here is what I can tell you:

1) My web.config does not have a namespace on it, my web.release.pittsburgh.config has the 'transform' namespace on it.

2) I copied the contents of a working web.release.pittsburgh.config into the none working one and it still didn't work.

3) When I publish a working site, in the output, I see some 'web config transform' output after a line like 'Publish Pipeline Collect Files Phase', and I see a step 'Transformed Web.config using...' and finally a 'Publish Pipeline Transform Phase' output line. In my none working project, I go from 'Publish Pipeline Collect Files Phase' directly to 'Publish Pipeline Transform Phase' with nothing in between.

I tried comparing the *.csproj files to look for anything obvious and I didn't see anything.

Let me know if you have any ideas or would like any specific information.


Solution

  • Please make sure below things are configured properly.

    1) "Release.Pittsburgh" configuration is available or not. If not click on configuration manager and add new configuration.

    enter image description here

    2) Once configuration is available in the list, click on "Configuration Manager" and make sure all project configurations are set appropriately for "Release.Pittsburgh". If not, set it.

    3) This last step is just to make sure transformations are getting added properly or not (Right click on web.config).

    enter image description here

    Once all are good, go for publish website.