I have multiple configurations and so I need different App.config files for the different environments/configurations. Question is how do I generate these separate files? I remember I used to be able to right click on the file and click on something to do it but I don't see anything to do that right now.
2 Answers
In my MVC projects, I can do that by Right clicking on the config file and then selecting Add Config Transforms
.
That should create new config files for all the different build configurations you have in your solution. For example, if your project has two configurations Debug
and Release
. Doing the above for web.config
should create two new config files, web.Debug.config
and web.Release.config
. You can then modify those config files accordingly. Here are instructions on how to do so.
Also, in case you don't have the Add Config Transform
option in your right click context menu, you can download the Web Publish Update
for Visual Studio which contains this feature.
If the Add Config Transform
option appears to be grayed out, here are some suggestions I have found:
- Do a full rebuild
- They might already exist - click on
Show All Files
in theSolution Explorer
(link). - You might not have multiple configurations defined. (link)
- Make sure you are working on a
Web Application
project and not aWeb Site
project. (link)
Edit: In case you are not working on a web project, you can use the SlowCheetah visual studio addin to enable xml transforms for arbitrary xml files. (link)

- 1
- 1

- 3,420
- 22
- 35
-
Problem is I don't have the Add Config Transforms option - I used to have it but I've got a new laptop now. What do I need to install? – Sachin Kainth Sep 12 '13 at 15:50
-
In fact it is not missing it is dissabled – Sachin Kainth Sep 12 '13 at 15:52
-
MVC is installed - yep - mvc 4. – Sachin Kainth Sep 12 '13 at 15:53
-
Apparently you need this http://msdn.microsoft.com/library/jj161045. Also, how do you know it's disabled? – Tejas Sharma Sep 12 '13 at 15:54
-
When I say disabled I mean the option is there but greyed out and not clickable. – Sachin Kainth Sep 12 '13 at 15:55
-
Oh I see. Do you have multiple configurations defined for your solution? If not, do that by going to `Build -> Configuration Manager`. Also, it could be that those files already exist, Try clicking on "Show All Files" in the solution explorer to check whether they already exist or not. – Tejas Sharma Sep 12 '13 at 15:58
-
I have 7 configurations defined. They don't exist. I'mm installing this update. – Sachin Kainth Sep 12 '13 at 16:00
-
Also, I just read in another stackoverflow post that transformation options are only available for `Web Application` projects and not for `Web Site` projects. Make sure you're working on a web application. – Tejas Sharma Sep 12 '13 at 16:00
-
it's actually a console app. – Sachin Kainth Sep 12 '13 at 16:07
-
Try this http://www.hanselman.com/blog/SlowCheetahWebconfigTransformationSyntaxNowGeneralizedForAnyXMLConfigurationFile.aspx – Tejas Sharma Sep 12 '13 at 16:12
Right Click on File. -> Add new Item -> Visual C# Items -> General-> create "Application Configuration file."

- 331
- 8
- 16
- 28