This used to be one of the most challenging issue that the majority of the developers come across when to deploy their application into a variety of environments such as development, test(or staging) and production. The problem increases linearly if the application is to be deployed to multiple customers since each of them may be expected to have their own development, test and production environments.
Visual Studio 2010 provides a lean solution , namely Web.Config Transformations, for this sticky problem. Below are simple tutorials about how to apply the solution.
Edit: It is possible now to apply configuration file transformation even for console applications with the following free extension that has recently been released.