【问题标题】:Replace config value in teamcity build step在 teamcity 构建步骤中替换配置值
【发布时间】:2018-08-19 13:47:13
【问题描述】:

我在 teamcity 中有一个构建步骤,它允许我用 web.release.config 值替换 web.config 值。我想再添加一步 - 将一些参数从 teamcity 传递到 web.config。在我的情况下,它将是发布版本,它是连接字符串的一部分。我最好的想法就是拥有一些powershell脚本,它将替换某些文件(web.config)中的文本。有没有更好的选择?

示例网络配置

 <add key="Version" value="Replace me, please from teamcity"/>
 <add key="some key" value="example 2. version as part of some value #VERSION"/>

【问题讨论】:

  • 请将您的 web.config 文件添加到问题中,请

标签: msbuild teamcity web.config-transform


【解决方案1】:

你可以使用File Content Replacer

【讨论】:

    【解决方案2】:

    您可以使用the web.config transformation syntax

    ,而不是在 TeamCity 的发行版中创建 web.config

    ie:创建特定的连接字符串:

    <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
      <connectionStrings>
        <add name="MyDB" 
      connectionString="value for the deployed Web.config file" 
      xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
     </connectionStrings>
    </configuration>
    

    【讨论】:

    • 我需要传递配置 teamcity 值。正如我所说,我有步骤来转换配置,但之后我需要步骤来修改转换结果。
    猜你喜欢
    • 2014-09-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-09
    • 2012-12-28
    • 2013-09-22
    • 1970-01-01
    相关资源
    最近更新 更多