首页 > 解决方案 > FileTransform@1 任务未按预期工作

问题描述

我正在使用 yaml FileTransform@1 来转换我的文件,但它不起作用。它只是跳过更新文件

尝试使用 xmlTransformationRules 并声明文件类型和 tragetfiles 但似乎没有任何效果

    - task: FileTransform@1
      inputs:
        folderPath: '$(build.artifactStagingDirectory)/**/${{ parameters.projectToDeploy }}.zip'         
        enableXmlTransform: true
        xmlTransformationRules: '-transform **\MyConfig.Dev.config -xml **\MyConfig.config -result **\MyConfig.config'        

MyConfig.config

<?xml version="1.0" encoding="utf-8"?>
<authenticationConfig xmlns:config="urn:telerik:sitefinity:configuration" xmlns:type="urn:telerik:sitefinity:configuration:type" config:version="11.1.6800.0">
    <securityTokenServiceSettings>
        <identityServerSettings enableLogging="True" mapUsersViaEmail="True" />
        <authenticationProviders>
                <add somecustomvalue ="1">
        </authenticationProviders>
    </securityTokenServiceSettings>
</authenticationConfig>

MyConfig.Dev.Config

<?xml version="1.0" encoding="utf-8"?>
<authenticationConfig xmlns:config="urn:telerik:sitefinity:configuration" xmlns:type="urn:telerik:sitefinity:configuration:type" config:version="11.0.6700.0"  xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <securityTokenServiceSettings xdt:Transform="Replace">
    <identityServerSettings enableLogging="True" mapUsersViaEmail="True" />
    <authenticationProviders >
      <add mynewvalue="2"/>
    </authenticationProviders>
  </securityTokenServiceSettings>
</authenticationConfig>

我得到的新错误是

2019-09-30T23:49:01.0338926Z ##[warning]Can\'t find loc string for key:FailedToApplySpecialTransformation 
2019-09-30T23:49:01.0348290Z ##[warning]FailedToApplySpecialTransformation

标签: azure-devopsazure-pipelinesazure-pipelines-release-pipeline

解决方案


这个问题是由于你为你的配置文件名写的不正确造成的。您应该将xmlTransformationRules值更改为'-transform **\MyConfig.Dev.config -xml **\MyConnfig.config -result **\MyConfig.config'。因为您将源 xml 文件名定义为MyConnfig.config.

请参阅此FileTransform 任务源代码。它的实际应用脚本是apply transform。您可以看到您收到的错误消息是因为isTransformationAppliedis false,并且由于文件名彼此不匹配,for因此无法执行循环。

在此处输入图像描述

错误消息的意思是抱歉,我认为您提供的文件与该规则提到的文件不匹配,因此我无法帮助您应用此转换过程。


第一个问题将得到解决,但现在,在您的MyConfig.Dev.Config文件中,它似乎是一个无效的 xml。因为我测试了您的配置文件,并收到错误消息:

The 'add' start tag on line 6 position 18 does not match the end tag of 'authenticationProviders'

在您的 MyConnfig.config 文件中,您丢失/了标签<add>


推荐阅读