【问题标题】:How to ignore special characters in File Transformation Task of Azure DevOps Pipeline如何忽略 Azure DevOps Pipeline 的文件转换任务中的特殊字符
【发布时间】:2022-06-28 11:08:44
【问题描述】:

我有如下的 xyz.config 文件。我创建了 xyx.Release.config 文件以在文件转换任务中使用。

 <formatters>

      <add template="Timestamp: {timestamp}&#xD;&#xA;Message: {message}&#xD;&#xA;  name="Reduced Text Formatter" />

</formatters>

在管道中的文件转换任务之后,它转换如下。文件转换任务执行后,特殊字符被替换。

<formatters>

        <add template="Timestamp: {timestamp}

消息:{消息}

-

</formatters>

请告诉我如何在文件转换任务中忽略特殊字符转换。

提前致谢。 磨难

【问题讨论】:

    标签: azure-devops azure-pipelines


    【解决方案1】:

    据我所知,文件转换任务不支持忽略特殊字符转换。

    文件转换任务将使用内置方法进行文件转换选项。不支持使用自定义方法做选项。

    这是关于内置方法的文档:Web.config Transformation Syntax for Web Project Deployment Using Visual Studio

    支持字符串整体替换,但目前不支持只替换字符串中值的一部分而忽略其他部分。

    对于一种解决方法,您可以使用替换方法,然后只需更改字符串中的值部分以保持字符串的格式。

    例如:xyx.Release.config

    <?xml version="1.0"?>
    <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
     <formatters>
         <add template="Timestamp: test1&#xD;&#xA;Message: test2&#xD;&#xA;"  name="Reduced Text Formatter" xdt:Transform="Replace" xdt:Locator="Match(template)"  />
     </formatters>
    </configuration>
    

    【讨论】:

      猜你喜欢
      • 2016-10-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-11
      • 1970-01-01
      • 2011-05-02
      • 1970-01-01
      相关资源
      最近更新 更多