1

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.

Sachin Kainth
  • 45,256
  • 81
  • 201
  • 304

2 Answers2

2

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:

  1. Do a full rebuild
  2. They might already exist - click on Show All Files in the Solution Explorer (link).
  3. You might not have multiple configurations defined. (link)
  4. Make sure you are working on a Web Application project and not a Web 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)

Community
  • 1
  • 1
Tejas Sharma
  • 3,420
  • 22
  • 35
1

Right Click on File. -> Add new Item -> Visual C# Items -> General-> create "Application Configuration file."

Animesh Ghosh
  • 331
  • 8
  • 16
  • 28