20

I’m a fan of the new VS 2010 Web.config transformations. I use this feature for deployment purposes and wondered if it is possible to use them for debugging too.

I think of using them in the IDE: I want to create different built configuration (with linked transformation configurations); choose one of them; start the web site in the IDE and debug the different configurations this way.

Sayed Ibrahim Hashimi
  • 43,864
  • 17
  • 144
  • 178
Dirk Brockhaus
  • 4,922
  • 3
  • 38
  • 47
  • Can you be a bit more descriptive? How would you use them for debugging, aside from the default of removing the debug attribute when sending to production? – Nick Craver Jun 07 '10 at 14:38
  • Edited my question. Hope it's descriptive enough. – Dirk Brockhaus Jun 07 '10 at 14:51
  • 2
    Ah, I don't think that's possible (it's using web.config right from the file system, doesn't move it at any point), the xdt in this case is specifically for deployment, not use locally...though you could deploy to a local directory and debug on IIS there... – Nick Craver Jun 07 '10 at 14:59

3 Answers3

12

Update

Thanks to a 3rd party plugin, SlowCheetah, this is now possible. Scot Hanselman has a blog post about it.


Original response:

Unfortunately, the web.config transformations appear to effect only publishing sites and building deployment packages.

In our scenario we have two development groups, one with access to multiple environments (in-house) and the other with access to a single environment (offshore). We have periods where the in-house group needs to debug directly against QA, while offshore remains locked-out (so their web.config's must point to the dev environment).

We were hoping to have 1x build-configuration per-environment, and be able to choose the build-configuration which matched the environment to debug against--which, as I understand it is your question.

STW
  • 44,917
  • 17
  • 105
  • 161
  • I come to the same conclusion. Your answer gives me the chance to close this issue :-) – Dirk Brockhaus Sep 01 '10 at 04:32
  • What a bummer... looking for this same feature. I want to mostly run on my local sql instance but it would be nice to select a different configuration and be able to apply my transforms to connect to the SQL box we use for our DEV server .. found in my DEV transformation already. – felickz Aug 30 '11 at 13:27
  • 5
    Even using SlowCheetah **it's NOT possible to do that.** It works exactly was you wrote, only in publishing sites and building deployment packages. – Fabito May 12 '12 at 02:45
  • This doesn't work for local debugging -- without the deploy -- see the answer by Alp with a link to: http://ledtalks.posterous.com/webconfig-transformations-when-debugging – Kem Mason Aug 20 '12 at 23:44
7

In case anyone is curious why they haven't built this feature, from: http://forums.asp.net/p/1532038/3711423.aspx

"When the web app gets run, the web.config under project root folder will be picked up by asp.net and I know unfortunately it is under source control . I certainly understand the cleanness coming with letting runtime use a transformed web.config from a temp folder; however, asp.net runtime doesn't know anything about vs projec structure and it is totaly based on directory structure. Using alternate path might also break as a web.config under a subfolder expect to inherit settings from the upper level of directory."

Dave K
  • 757
  • 7
  • 15
  • 1
    There is a solution at the end of page 2 on this post that runs MSDEPLOY as a build event then XCOPY's the transformed config over top of the debugging web.config as a post build event. Only issue is that if you have solution under source control you will be checking out the web.config with every build :( – felickz Aug 30 '11 at 13:38
7

I found an alternative solution that does not involve any third party tool: http://ledtalks.blogspot.in/2011/09/webconfig-transformations-when.html. I only tried this for the web.config file

fordareh
  • 2,923
  • 2
  • 26
  • 39
Alex Pop
  • 655
  • 1
  • 11
  • 20
  • 1
    I love this solution, thanks v. much to JAMES COLEMAN (a legend and a sir). – MemeDeveloper Aug 02 '12 at 05:46
  • Also, anyone having problems with write access to the web.config locally using this solution... if you visit that blog I added a comment with a simple solution. Chrs – MemeDeveloper Aug 02 '12 at 08:14
  • Thanks for the praise and referral Chris. I found this post because I was looking at my google analytics and a number of visits came from here. – Colema18 Jan 29 '13 at 21:15
  • Beautiful and elegant solution. If I could upvote more I would. – Jay May 16 '13 at 19:43
  • This solution doesn't seem to handle scenarios where the Web.config is automatically updated and the updates are overwritten when building. – TonE May 29 '13 at 13:52
  • You need to ensure that any change for Web.config other than this transformation ocurrs as a pre-build step. – Alex Pop May 29 '13 at 14:33
  • What about the example given by Michael Bunney here: http://slowcheetah.uservoice.com/forums/185106-general/suggestions/3385389-support-for-transforming-web-config-on-f5 (if you add a web service reference where the IDE then adds the endpoints and bindings automatically to the web.config)? – TonE May 29 '13 at 15:08
  • Hi TonE, I think you need to ask a new question and post all the relevant detail about your specific scenario in order to progress with your issue. – Alex Pop May 30 '13 at 12:45
  • 1
    The images in the blog post are gone, anyone could explain the solution better? – Leandro Gomide Aug 14 '13 at 20:26