Answers: <p>In your <a href="https://confluence.atlassian.com/bamboo/deployment-projects-338363438.html" rel="nofollow noreferrer">deployment project configuration</a> for each environment you could <a href="https://confluence.atlassian.com/bamboo/a-sample-deployment-project-365658897.html#Asampledeploymentproject-Step4:Addsomeenvironmenttasks" rel="nofollow noreferrer">add a task</a> prior to the actual deployment which would take care of setting up the right configuration file. </p>
  
  <p>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 <a href="https://confluence.atlassian.com/bamboo/a-sample-deployment-project-365658897.html#Asampledeploymentproject-Step7:Additionaldeploymentenvironmentoptions" rel="nofollow noreferrer">Additional deployment environment options</a></p>
  
Answers: CC BY-SA 4.0
Answers: 2018-11-04T03:49:14.177Z
Answers: 2018-11-04T03:49:14.177Z
Answers: Dan Cornilescu
Body: <p>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.</p>
  
  <p>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.</p>
  
  <p>Now my question is how do I dynamically change the AppConfig for different environment deployments.</p>
  
  <p>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.</p>
  
  <p>Can anyone guide me in the right direction for my issue?  </p>
  
  <p>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.</p>
  
Tags: <continuous-integration><configuration><builds><bamboo>
Title: Dynamically change config files in c# Application based on environments(dev,QA,Prod) through Bamboo
UserDisplayName: CrazyCoder
ThreadText: # Dynamically change config files in c# Application based on environments(dev,QA,Prod) through Bamboo
  
  (Asked by: username_0 on 2018-10-26)
  
  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.
  
  **Tags:** continuous-integration, configuration, builds, bamboo
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-11-04. Score: 1
  
  In your [deployment project configuration](https://confluence.atlassian.com/bamboo/deployment-projects-338363438.html) for each environment you could [add a task](https://confluence.atlassian.com/bamboo/a-sample-deployment-project-365658897.html#Asampledeploymentproject-Step4:Addsomeenvironmenttasks) 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](https://confluence.atlassian.com/bamboo/a-sample-deployment-project-365658897.html#Asampledeploymentproject-Step7:Additionaldeploymentenvironmentoptions)
  
  
  ---
  
  