We have solved this with two types of files. One is Environment Definition file, which contains all key-value mappings of specific deployment enviornment say prod1,prod2 etc. and our web.config files will only have keys representing connectiongstring etc. variables. e.g. <ConnectionString name="abc" value="$$env.def.key$$"/>. At the time of deployment, our Jenkins script replaces keys like $$env.def.key$$ with actual prod1 or prod2 values. This helps us to keep our code seperate from enviornment specific things as well as helps to maintain security.
↧