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
Not quite the same, but you can preview transformations using Visual Studio 2012+
Note: if you're using SlowCheetah you need to save the file before you preview.
-
1This works quite well, will show you in 'diff' format what has been transformed.– JazzyCommented Dec 10, 2014 at 21:58
-
1
-
2
-
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. Commented May 28, 2019 at 9:47
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.
-
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
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.
-
3Jimmy, 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
-
1I 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