【问题标题】:Azure pipeline transforming web.config files during releaseAzure 管道在发布期间转换 web.config 文件
【发布时间】:2019-11-12 19:00:01
【问题描述】:

我正在尝试在我的发布管道中使用 web.config 转换。但是,无论我在做什么,我总是得到 ​​p>

2019-11-11T12:19:46.1172474Z ##[warning]Unable to apply transformation for the given package. Verify the following.

我有一个Web.config 和一个Web.Elastic.config。该项目的 csproj 中没有任何 .config 文件的依赖项,Web.Elastic.config 具有作为构建操作的内容,并且位于从构建任务生成的 zip 文件中。

此外,为了确定,我在构建过程中禁用了配置转换。我不确定我还能做什么。在 IIS Web App 部署任务期间使用文件转换任务预览和 XML 转换选项时都会发生这种情况。

文件转换任务配置如下:

我将我的配置简化为这个,看看转换本身是否有问题:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="apiConfig" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
  </configSections>
  <apiConfig>
    <add key="ClientBasetUrl" value="http://localhost:4200" />
  </apiConfig>
  <system.web>
    <compilation debug="true" targetFramework="4.6.2">
      <assemblies>
        <add assembly="System.Net.Http.WebRequest, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
      </assemblies>
    </compilation>
    <!-- This will handle requests up to 20MB -->
    <httpRuntime targetFramework="4.6.1" maxRequestLength="20480" />
  </system.web>
</configuration>

转换看起来像这样:

<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">

  <apiConfig xdt:Transform="Replace">
    <add key="ClientBasetUrl" value="https://elastic.OURPROJECT.com" />
  </apiConfig>
  <system.web xdt:Transform="Replace">
    <customErrors mode="Off" />
    <compilation debug="true" targetFramework="4.6.2" />
    <httpRuntime targetFramework="4.6.1" maxRequestLength="20480" />
  </system.web>
</configuration>

将 System.Debug 设置为 true,文件转换任务提供以下日志,这些日志不是很有帮助:

2019-11-11T12:19:43.1224281Z ##[debug]agent.TempDirectory=C:\vstsagent\A1\_work\_temp
2019-11-11T12:19:43.1289319Z ##[debug]loading inputs and endpoints
2019-11-11T12:19:43.1292645Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
2019-11-11T12:19:43.1301246Z ##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
2019-11-11T12:19:43.1304962Z ##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
2019-11-11T12:19:43.1307442Z ##[debug]loading INPUT_ENABLEXMLTRANSFORM
2019-11-11T12:19:43.1309334Z ##[debug]loading INPUT_FILETYPE
2019-11-11T12:19:43.1316311Z ##[debug]loading INPUT_FOLDERPATH
2019-11-11T12:19:43.1316632Z ##[debug]loading INPUT_XMLTRANSFORMATIONRULES
2019-11-11T12:19:43.1322390Z ##[debug]loaded 7
2019-11-11T12:19:43.1334690Z ##[debug]Agent.ProxyUrl=undefined
2019-11-11T12:19:43.1336439Z ##[debug]Agent.CAInfo=undefined
2019-11-11T12:19:43.1336699Z ##[debug]Agent.ClientCert=undefined
2019-11-11T12:19:43.1336884Z ##[debug]Agent.SkipCertValidation=undefined
2019-11-11T12:19:43.2867243Z ##[debug]check path : C:\vstsagent\A1\_work\_tasks\FileTransform_8ce97e91-56cc-4743-bfab-9a9315be5f27\1.1.6\task.json
2019-11-11T12:19:43.2867893Z ##[debug]adding resource file: C:\vstsagent\A1\_work\_tasks\FileTransform_8ce97e91-56cc-4743-bfab-9a9315be5f27\1.1.6\task.json
2019-11-11T12:19:43.2868317Z ##[debug]system.culture=en-US
2019-11-11T12:19:43.2882674Z ##[debug]check path : C:\vstsagent\A1\_work\_tasks\FileTransform_8ce97e91-56cc-4743-bfab-9a9315be5f27\1.1.6\node_modules\webdeployment-common-v2\module.json
2019-11-11T12:19:43.2883957Z ##[debug]adding resource file: C:\vstsagent\A1\_work\_tasks\FileTransform_8ce97e91-56cc-4743-bfab-9a9315be5f27\1.1.6\node_modules\webdeployment-common-v2\module.json
2019-11-11T12:19:43.2884521Z ##[debug]system.culture=en-US
2019-11-11T12:19:43.2900694Z ##[debug]folderPath=C:\vstsagent\A1\_work\r2\a\SLX-Backend\drop\OURPROJECT.zip
2019-11-11T12:19:43.2902832Z ##[debug]Finding files matching input: C:\vstsagent\A1\_work\r2\a\SLX-Backend\drop\OURPROJECT.zip
2019-11-11T12:19:43.2907625Z ##[debug]fileType=xml
2019-11-11T12:19:43.2908713Z ##[debug]targetFiles=null
2019-11-11T12:19:43.2911002Z ##[debug]enableXmlTransform=true
2019-11-11T12:19:43.2912768Z ##[debug]xmlTransformationRules=-transform **\OURPROJECT\obj\Release\Package\PackageTmp\Web.Elastic.config -xml **\OURPROJECT\obj\Release\Package\PackageTmp\Web.config
2019-11-11T12:19:43.2916829Z ##[debug]This is zip package 
2019-11-11T12:19:43.2919443Z ##[debug]Agent.TempDirectory=C:\vstsagent\A1\_work\_temp
2019-11-11T12:19:43.2919672Z ##[debug]Agent.TempDirectory=C:\vstsagent\A1\_work\_temp
2019-11-11T12:19:43.2927405Z ##[debug]extracting C:\vstsagent\A1\_work\r2\a\SLX-Backend\drop\OURPROJECT.zip to C:\vstsagent\A1\_work\_temp\temp_web_package_9699193652416063
2019-11-11T12:19:45.9624316Z ##[debug]extracted C:\vstsagent\A1\_work\r2\a\SLX-Backend\drop\OURPROJECT.zip to C:\vstsagent\A1\_work\_temp\temp_web_package_9699193652416063 Successfully
2019-11-11T12:19:46.0225418Z ##[debug]defaultRoot: 'C:\vstsagent\A1\_work\_temp\temp_web_package_9699193652416063'
2019-11-11T12:19:46.0225668Z ##[debug]findOptions.allowBrokenSymbolicLinks: 'false'
2019-11-11T12:19:46.0225791Z ##[debug]findOptions.followSpecifiedSymbolicLink: 'true'
2019-11-11T12:19:46.0225928Z ##[debug]findOptions.followSymbolicLinks: 'true'
2019-11-11T12:19:46.0226038Z ##[debug]matchOptions.debug: 'false'
2019-11-11T12:19:46.0226147Z ##[debug]matchOptions.nobrace: 'true'
2019-11-11T12:19:46.0226280Z ##[debug]matchOptions.noglobstar: 'false'
2019-11-11T12:19:46.0226387Z ##[debug]matchOptions.dot: 'true'
2019-11-11T12:19:46.0226547Z ##[debug]matchOptions.noext: 'false'
2019-11-11T12:19:46.0226657Z ##[debug]matchOptions.nocase: 'true'
2019-11-11T12:19:46.0226763Z ##[debug]matchOptions.nonull: 'false'
2019-11-11T12:19:46.0226896Z ##[debug]matchOptions.matchBase: 'false'
2019-11-11T12:19:46.0227016Z ##[debug]matchOptions.nocomment: 'false'
2019-11-11T12:19:46.0227146Z ##[debug]matchOptions.nonegate: 'false'
2019-11-11T12:19:46.0227252Z ##[debug]matchOptions.flipNegate: 'false'
2019-11-11T12:19:46.0227392Z ##[debug]pattern: '**\OURPROJECT\obj\Release\Package\PackageTmp\Web.config'
2019-11-11T12:19:46.0227519Z ##[debug]findPath: 'C:\vstsagent\A1\_work\_temp\temp_web_package_9699193652416063'
2019-11-11T12:19:46.0227632Z ##[debug]statOnly: 'false'
2019-11-11T12:19:46.0227769Z ##[debug]findPath: 'C:\vstsagent\A1\_work\_temp\temp_web_package_9699193652416063'
2019-11-11T12:19:46.0227885Z ##[debug]findOptions.allowBrokenSymbolicLinks: 'false'
2019-11-11T12:19:46.0228032Z ##[debug]findOptions.followSpecifiedSymbolicLink: 'true'
2019-11-11T12:19:46.0228152Z ##[debug]findOptions.followSymbolicLinks: 'true'
...
2019-11-11T12:19:46.0970036Z ##[debug]615 results
2019-11-11T12:19:46.0970193Z ##[debug]found 615 paths
2019-11-11T12:19:46.0970374Z ##[debug]applying include pattern
2019-11-11T12:19:46.0970559Z ##[debug]adjustedPattern: 'C:\vstsagent\A1\_work\_temp\temp_web_package_9699193652416063\**\PackageTmp\Web.config'
2019-11-11T12:19:46.1099930Z ##[debug]1 matches
2019-11-11T12:19:46.1100207Z ##[debug]1 final results
2019-11-11T12:19:46.1172474Z ##[warning]Unable to apply transformation for the given package. Verify the following.
2019-11-11T12:19:46.1179673Z ##[debug]Processed: ##vso[task.issue type=warning;]Unable to apply transformation for the given package. Verify the following.

【问题讨论】:

  • 我猜这意味着你认为不是?你能解释一下为什么不吗?我认为 Azure DevOps 是一个常用的工具,并且已经有关于这个主题的各种问题被问到,例如hereherethis similar question
  • 服务器配置问题不在主题范围内,应该在serverfault.com 上询问您应该删除它并在那里询问。
  • 我认为我在选择标题方面做得不好。更改了标题以更清楚地说明这与 Azure DevOps Server 配置无关。
  • 只是想看看下面是否对你有用。您现在仍然面临任何错误吗?如果仍然遇到任何难题,请随时在下面发表评论。如果有帮助,您可以accept it,这也将帮助社区中的其他人

标签: azure-devops


【解决方案1】:

正如您在上面分享的配置文件中的配置,在我这边应用时没有任何问题。

实际上,在你的构建日志中,它已经告诉你问题是由什么引起的。

您可以看到该任务只找到了一个文件,而这里它应该匹配 2 个文件,如下所示:

这两个文件,一个是配置文件,另一个是转换配置文件。但是在您的构建中,它只能找到一个文件(不确定您共享的日志是否完成,如我所见,它只检测到Web.config文件)。


此问题应该与您的任务配置相关。似乎您正在链接工件,并希望将转换应用到其中。

请修改包或文件夹空白,如图所示:

并将您的转换规则更改为:

-transform **\*.Elastic.config -xml **\*.config

【讨论】:

  • 感谢您的回复。我不得不一直链接神器,否则将无法正常工作,但转换规则的更改确实解决了问题。我决定在那里特别具体,因为那里还有其他配置文件,但似乎是导致问题的原因。它现在按预期工作。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-05-01
  • 2019-11-22
  • 1970-01-01
  • 2021-03-06
  • 2020-01-17
  • 2014-05-30
  • 1970-01-01
相关资源
最近更新 更多