0

I have a web service project where I have one main web.config file and then different environment specific files as well like web.Staging.config/web.QE.config etc. Now, I am following this: http://www.hanselman.com/blog/ManagingMultipleConfigurationFileEnvironmentsWithPreBuildEvents.aspx to add a prebuild event to my project to copy the configuration specific config file to the main web.config file but the problem is, it copies it without transforming and hence resulting into something like below:

<add key="somekey" value="Development" xdt:Transform="Replace" xdt:Locator="Match(key)"/>

My question is, is there a way to keep the transformed config files ready to be copied while building the project?

tavier
  • 1,744
  • 4
  • 24
  • 53
  • Surely the point of multiple configurations is that you select the appropriate configuration before building and the build process applies the transformations in the configuration specific config files to the 'main' web.config file? – spodger Oct 27 '17 at 10:51
  • The file is transformed according the build configuration. So if you are in debug the debug transform will run. If in release, then that one, and so on. – Crowcoder Oct 27 '17 at 10:51
  • problem is, it works fine for Release configuration but doesn't transform when I use QE or some other custom build configurations in bamboo – tavier Oct 27 '17 at 10:57

1 Answers1

1

You can use SlowCheetah to do the transform for you.This work with multiple environment QA, UAT etc. This also has provided as nuget package

https://marketplace.visualstudio.com/items?itemName=VisualStudioProductTeam.SlowCheetah-XMLTransforms

Recent new feature in 2017 15.8.4 has feature for managing secret. Its worth to have a look https://channel9.msdn.com/Shows/Visual-Studio-Toolbox/Managing-User-Secrets/?utm_source=vs_developer_news&utm_medium=referral

duongthaiha
  • 855
  • 6
  • 17
  • I'm surprised that as of VS2017 we're still in need of Slow Cheetah, but alas it's still a strong tool and practically a required add-on. – Kevin Matlock Jul 25 '18 at 23:45