结构化变量替换不适用于 web.config (XML)

Structured variable replacement not working for web.config (XML)

八达通服务器 2021.1

我正在尝试使用结构化变量替换功能来替换 web.config (XML) 文件的部分内容,但它只尝试将文件读取为 Json 和 Yaml 但不是 Xml。该变量的名称如下:/configuration/system.webServer/rewrite/rules/rule/action/@url,其中@url 是元素的属性。 我尝试了很多东西,但似乎无法将 web.config 文件视为 XML 文件 - 有没有人有过在 Octopus Deploy 中使用这种类型的替换的经验?

web.config 中的代码如下所示:

  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <rewrite>
      <rules>
        <rule name="ReverseProxyInboundRule1" stopProcessing="true">
          <match url="^api/(.*)" />
          <action type="Rewrite" url="http://localhost:8053/api/{R:1}" appendQueryString="true" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
||15:22:17   Verbose  |       The file at C:\Octopus\Work210612032325-158854-2674\staging\Web.config does not match any known filename patterns. The file will be tried as multiple formats and will be treated as the first format that can be successfully parsed.|
|---|---|
||15:22:17   Verbose  |       Attempting structured variable replacement on file C:\Octopus\Work210612032325-158854-2674\staging\Web.config with format Json|
||15:22:17   Verbose  |       The file at C:\Octopus\Work210612032325-158854-2674\staging\Web.config couldn't be parsed as Json: Unexpected character encountered while parsing value: <. Path '', line 0, position 0.|
||15:22:17   Verbose  |       Attempting structured variable replacement on file C:\Octopus\Work210612032325-158854-2674\staging\Web.config with format Yaml|
||15:22:17   Info     |       No structures have been found that match variable names, so no structured variable replacements have been applied.|
||15:22:17   Info     |       Structured variable replacement succeeded on file C:\Octopus\Work210612032325-158854-2674\staging\Web.config with format Yaml|
||15:22:17   Verbose  |       The file at C:\Octopus\Work210612032325-158854-2674\staging\Views\Web.config does not match any known filename patterns. The file will be tried as multiple formats and will be treated as the first format that can be successfully parsed.|
||15:22:17   Verbose  |       Attempting structured variable replacement on file C:\Octopus\Work210612032325-158854-2674\staging\Views\Web.config with format Json|
||15:22:17   Verbose  |       The file at C:\Octopus\Work210612032325-158854-2674\staging\Views\Web.config couldn't be parsed as Json: Unexpected character encountered while parsing value: <. Path '', line 0, position 0.|
||15:22:17   Verbose  |       Attempting structured variable replacement on file C:\Octopus\Work210612032325-158854-2674\staging\Views\Web.config with format Yaml|
||15:22:17   Info     |       No structures have been found that match variable names, so no structured variable replacements have been applied.|
||15:22:17   Info     |       Structured variable replacement succeeded on file C:\Octopus\Work210612032325-158854-2674\staging\Views\Web.config with format Yaml|

这应该基于 docs

这可能是一个错误。现在最好的行动是将详细信息和完整的日志文件通过电子邮件发送给 support@octopus.com 以供诊断。

对于 .NET 配置文件,您可以使用另一种模式来获得与 docs 中详述的相同结果,该模式涉及在文件中组合配置文件转换和替换变量模板。