One way to deal with such things, and I'm not sure if this is the best, but this is the way is to set certain configuration values โโat a higher level on the web.config or machine.config file, which is always on the machine in question.
Then just make sure your project files do not override these configuration values.
Here are some considerations if you do.
- If you want the initial control of these values, it can be more difficult this way (it can be pro or con depending on your environment).
- If other virtual sites are on the same machine and use the same configuration value, this can affect them all, and if several sites use the same configuration value, changing it to the source will change them all (again, maybe about or con depending).
- If something is wrong with the meaning, it may be more difficult to determine where the problem is or what causes it.
- Access to machine.config can be difficult in your organization or with your hosting provider depending on your access / security privileges, and it is not always possible to put web.config at a higher level than your application.
Obviously, itโs good that you can have a different value configured on each computer, and until these values โโare also set in your web.config (which will probably lead to an error), you wonโt have to worry about compiling different versions.
I believe that Visual Studio 2010 has a way to install different configuration files for different types of assemblies, but this is very similar to what you are already doing, so forgetting to build the right path can still lead to similar results.
You can try to configure continuous integration with something like TFS Build, if it is available to you, in which case what is created for prod can be configured to always work in a certain way and always extract from the correct build type.
Hope something helps here.
source share