Using msbuild I want to update a config file with values from teamcity

前端 未结 2 906
臣服心动
臣服心动 2021-01-30 01:26

I have some XML that looks something like this:




        
2条回答
  •  囚心锁ツ
    2021-01-30 01:51

    We change config values for our different build environments (e.g. dev, staging, production) using config transformations. I assume that config transforms probably won't work for you, but if it's a possibility, check out this answer which shows how to apply .Net config transforms to any XML file.

    An alternative would be to use the FileUpdate build task from the MSBuild Community Tasks project. This task allows you to use regular expressions to find and replace content in a file. Here's an example:

    Because you'd be passing TeamCity system properties into FileUpdate if you decide to go with the second option, take a look at this question to see how system properties can be referenced in an MSBuild script.

提交回复
热议问题