Question

We are using TFS 2010. In our projects we have multiple configuration files. Each configuration file is needed for a specific build.

Example: Project XYZ includes three configuration files, lets say DEV-CONFING, QA-CONFIG and PROD-CONFIG files.

Now we want to find a way that during the build process, the build process includes the right configuration file and excludes the rest.

Example:

  1. Build for Dev should pickup and copy only the DEV-CONFIG file (and excludes all other configuration files)

  2. Build for QA should pickup and copy only the QA-CONFIG file (and excludes all other configuration files)

  3. Build for production should pickup and copy only the PROD-CONFIG file (and excludes all other configuration files)

Is it possible to change the setting of individual build definition and address this issue?

What is best possible solution for this problem in VS 2010 and TFS 2010?

Please list all required steps and be precise as much as possible because I'm a newbie in TFS 2010 and have not much experience with the whole process.

Was it helpful?

Solution

The "Web Config Transformations in VS2010" addresses the problem of modifying the web.config during compile time. Some people might want the web.config to be modified at deployment time instead of compile time (like me) so that we dont have to recompile the code while moving from one environment to another, in that case you can make use of "Web Deployment Parameters"

You can read more about it at:

http://www.asp.net/mvc/tutorials/deployment/visual-studio-web-deployment/web-config-transformations

web config transformation syntax:

http://msdn.microsoft.com/en-us/library/dd465326.aspx

@user2585405 to your comment above "But all the configurations in my case are for the same mode "Release Mode". The decision should relay on the build definition. So when I use a build definition for DEV, the configuration for DEV should be automatically chosen or for QA build definition, the corresponding QA configuration should be automatically chosen."

Doesnt matter whether currently you have only one configuration. You can add how much ever configurations you want, right click the solution and select the configuration manager. Now add a new configuration say "Dev" (it can be in "Release/Debug" and also select the platform "x86, any cpu etc"). Now add another configuration for QA and PROD. Then come back to your web.config and right click and select "Add web config transformation".

Now you should be able to see the web.Dev.Config, web.QA.config etc. The root web.config will have all the common properties and the DEV/QA/Prod specific config will have only the delta changes (you have to define these entries) which are specific to that configuration (lets say connectionstring). When you compile, within the build definition you can select which configuration you want to compile (Dev, QA, prod) you dont have to keep multiple build defintion. Just one is enough! After the compilation is done, the root web.config will be replaced with the values specific to the configuration for the connectionstring part alone.

Hope this helps!

OTHER TIPS

Yes this possible. You can keep configuration files in different mode for eg: You can have configuration files in Release mode debug mode, release mode and the common configuration file used by all.

So when you build your solution in Debug mode then the debug mode configuration file will be used and when in release mode then release mode configuration file will be used.

For further clarity take example of web config when you will expand the web config tab you will see the two configuration file in different modes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top