azure-devops - 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
解决方案
这个问题是由于你为你的配置文件名写的不正确造成的。您应该将xmlTransformationRules
值更改为'-transform **\MyConfig.Dev.config -xml **\MyConnfig.config -result **\MyConfig.config'
。因为您将源 xml 文件名定义为MyConnfig.config
.
请参阅此FileTransform 任务源代码。它的实际应用脚本是apply transform。您可以看到您收到的错误消息是因为isTransformationApplied
is 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>
推荐阅读
- elasticsearch - 如何编写在 Elasticsearch 中执行多项任务的搜索查询?
- android - Room Database 继承数据类
- powershell - 使用批处理或外壳替换子文件夹中的文件(如果存在)
- azure-devops - “kubeconfig”选项的 Azure Devops kubernetes 服务连接似乎不适用于 AAD openidconnect 集成 AKS 群集
- java - 我应该如何为 LinkedList 定义 contains() 命令?
- typescript - 为什么 VS Code 无法调试具有 TS 3.7.1-rc 语法支持的源代码?
- python - conda 将 cutadapt 的最新版本列为 2.6,但仅运行 cutadapt 2.4
- ruby-on-rails - 使用 jruby 进行 Rails 测试
- sas - 如何删除所有外来字符SAS
- localhost - 本地开发多个微服务