How to inject Teamcity's build parameters into web.config

Hi everyone,

We have an ASP.NET MVC project deployed with Teamcity (Professional 7.1.3 (build 24266)).
Our project's web.config file contains database connection strings and some other security settings.
This web.config file resides on our VCS server as well as on our local development machines.
In this way, our database credentials and other security settings would be exposed to someone else if they get access to our development machines.

We want to move these secret information away from the web.config file and keep them as Teamcity's build parameters.
During the build or deployment process, these parameters need to be embedded into the production version of the web.config file.

Teamcity's documentation suggests that we can transform the test version of the web.config file to get its production version on deployment.
However, we don't know how to apply Teamcity's build parameters in this transformation process.

Please advise.

1 comment
Comment actions Permalink

Hi Hari,

You can pass needed parameter into MSBuild script (you should replace . with _ in the property name) and then update web.config file using MSBuild XmlUpdate task (for example see http://stackoverflow.com/questions/1271840/how-do-i-update-an-xml-attribute-from-an-msbuild-script).

0

Please sign in to leave a comment.