1

I have a windows service written in .net c#. We have three different environments say dev, test and prod. I also have 3 different config files for 3 environments say devAppConfig , TestAppConfig and ProdAppConfig.

Earlier, we used to deploy manual, so we used to replace the config files and deploy the binaries.Now the deployments are to be automated for that we are using Bamboo.

Now my question is how do I dynamically change the AppConfig for different environment deployments.

I have 3 different stages in Bamboo naming DevDeploy , TestDeploy, ProdDeploy. When I run these stages, it has to change the config file and do the deployment, but I'm not sure how.

Can anyone guide me in the right direction for my issue?

Note: I could have added a prebuild event to copy the appropriate config file before building the code. But the main aim here is to able to use the same binaries across all the environments without building it every time.There has to be some setting somewhere (not sure where) to determine which environment it is being deployed and use the appropriate config file.

1

In your deployment project configuration for each environment you could add a task prior to the actual deployment which would take care of setting up the right configuration file.

It could be a script simply copying/replacing the configuration file just as you currently do manually. The script could be invoked with some pre-configured argument to identify the environment or it could detect the environment via some environment variable configured for each the deployment, see Additional deployment environment options

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.