【问题标题】:File transformation, is it possible to add autoincrement to a setting文件转换,是否可以在设置中添加自动增量
【发布时间】:2011-09-27 09:09:55
【问题描述】:

在我们的自动构建中,我们将 MSBuild 与 web.config transformation 结合使用来创建验收配置和生产配置。

我们添加了属性来更改配置设置

例如更改cdn url。

<add key="cdn1url" value="http://cdn.acceptance.oursite.com/"
                   xdt:Transform="SetAttributes" 
                   xdt:Locator="Match(key)" />

有人知道是否可以添加自动增量属性吗?我们希望在每个生产版本上将+1 添加到版本属性(用于css/img/js 缓存)。

另一个选项可能是Teamcity 内部版本号,但我不确定这是否可能

【问题讨论】:

    标签: asp.net msbuild build-automation teamcity transformation


    【解决方案1】:
    1. 您已经拥有当前甚至下一个版本号作为 msbuild 属性值 - 请参阅 3
    2. 你没有 -> 在底部查看PS,然后返回3
    3. 您可以使用FileUpdate 任务通过提供正则表达式和替换文本以及新版本号来实现:

     <FileUpdate
          Files="@(FilesToUpdate)"
          Regex="regex here"
          ReplacementText="$(NextVersionNumber)" />
    

    PS:通过使用RegexMatch 任务,您可以提取当前版本,然后通过递增它,您将获得$(NextVersionNumber) proeprty 的值。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-11
      • 1970-01-01
      相关资源
      最近更新 更多