Visual Studio not running correctly transformed config file

Viewed 841

My approach here may be wrong, so apologies if so - I'd appreciate any advice on what I did wrong.

I need to run (locally, for debugging), a specific configuration of a project that contains specific web.config transforms.

In my solution, in Configuration Manager I have the following listed:

  • Debug
  • Release
  • ClientFoo (copied from Release)
  • ClientBar (copied from Release)

I created a new entry, ClientXYZ (copied from Debug), then right-clicked web.config and chose Add Config Transform. I applied the transform rules, and when previewed, the transforms display correctly.

When I select ClientXYZ in the solution config drop down, and start the debugger...

enter image description here

...I see that the web.config used to initiate the application is the Debug one, and not my new ClientXYZ version.

Is it possible to run the project locally with web.config transforms applied, for debugging?

2 Answers

Web config transforms are only applied during publishing or building deployment packages by default (it does, after all, overwrite web.config). There is a way with some adjustments, however, described in this answer: https://stackoverflow.com/a/35561167/1464084

The purpose of using "Debug" and "Release" in Visual Studio are:

  • Debug constant defined in Debug configuration when you are developing application
  • Release optimize code enabled in Release configuration when you host that application for client side testing or publishing
  • Custom (ClientXYZ) constant defined for a developer's own settings (localhost or different IP's) for both Client site hosting and publishing your site
Related