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?
I suppose this would work:
- Create few configuration files in some directory in the solution in the format Config.ConfigurationName.xml, eg Config.DEV.xml, Config.Test.xml...
- Add PreBuild event (by the csproj properties window or manually in the csproj file), for example:
<PropertyGroup><PreBuildEvent>xcopy /y (ProjectDir)\Configs\Config.$(Configuration).xml $(ProjectDir)\CONFIG\Config.xml</PreBuildEvent></PropertyGroup>
or in VS rigth click on the project -> Properties:
- Add few configurations in VS in Configuration Manager for different configuration eg. DEV, Test.
My project configuration:
- Execute in the Bamboo msbuild with arguments:
/p:SolutionConfiguration=%CONFIGURATION%
where %CONFIGURATION% is a variable in Bamboo saying on which ENV you are deploying, eg DEV, Test etc.