37

Does Visual Studio 2012 support running a solution using a specific Web.config transform without the requirement to publish? We are using the web.config to change client settings on publish and want to test them locally.

3 Answers 3

43

Not quite the same, but you can preview transformations using Visual Studio 2012+

Preview transformation

Note: if you're using SlowCheetah you need to save the file before you preview.

6
  • 1
    This works quite well, will show you in 'diff' format what has been transformed.
    – Jazzy
    Commented Dec 10, 2014 at 21:58
  • 1
    This one should be an answer Commented Apr 28, 2017 at 12:36
  • 2
    This allows you to preview but not apply as far as I can see
    – John
    Commented Oct 16, 2018 at 15:10
  • This isn't the answer because it is only a preview. @Sayed is correct, when you run debug on the site from VS, the unmodified web.config file is still being used. The only way this suggestion could be used is if you Preview and then copy/paste what it creates over the original web.config file. This would work but it's clunky and you risk forgetting to put the original back. Commented Apr 3, 2019 at 18:16
  • @ScriptWolf agreed, who knows what I was thinking 5 years ago... But it seems to have been useful to a large number of people so I'd feel bad removing it.
    – Rob Church
    Commented May 28, 2019 at 9:47
21

The web.config transform feature is only available during publish/package.

The deal with this is that web projects don't have the abstraction of an alternate folder where the app executes versus the folder where the source is located like win project have. Because of this a lot of VS code touches the source web.config. If the web.config file itself if modified without VS knowing it may lead to strange behavior.

I have blogged how you can manually do this at http://sedodream.com/2010/10/21/ASPNETWebProjectsWebdebugconfigWebreleaseconfig.aspx.

There has been a lot of people asking for this feature, even though it may put their web projects into a potentially bad state. Since the demand is soo high I am considering adding a gesture in SlowCheetah that will enable this for web projects as well. I've got an issue on the SlowCheetah project page at https://github.com/sayedihashimi/slow-cheetah/issues/39 to track this. You can follow that issue for further updates. This may be one of the next items that I work on, but in the mean time you can use the instructions at the link above.

1
  • I see Sayed's point on this. Using it for a console app makes sense because the bin/Debug folder (or other configuration) is where it actually executes on F5. You'd almost have to temporarily write the web.config, then overwrite it again if you stopped debugging. But what if you are running the project in real IIS and don't need to hit F5 to start the web server? This doesn't seem like the best idea, rather to have a separate local IIS server you can run tests on after publishing. Commented Apr 9, 2014 at 21:14
6

You should look into the SlowCheetah extension for VS. It enables XML transforms when you F5, in addition to publishing. It also enables transforms for more than just web.config.

2
  • 3
    Jimmy, have you tried SlowCheetah with VS2012? When you switch between configurations and hit F5 (no publish) does your VS pickup the web.config with the right transformation applied? Commented Nov 14, 2012 at 6:55
  • 1
    I second to @Filippo it never worked for me in VS2012 and VS2013. Alternatives are there as suggested by Sayed but all look hacky for me as well :) Commented Aug 11, 2013 at 8:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.