我正在尝试为我的配置文件设置令牌替换。我将源文件名设置为:
$(System.DefaultWorkingDirectory)/TFS Web Build 1.0/Corporate Art\app.RM.config
(这里,RM文件是使用令牌的标记化配置文件)
目标文件名设置为配置文件的真实名称:
Company.Client.Corporate.exe.config
我在构建服务器上有json文件:
\0111-03-0555-01\c$\BuildFiles\Transforms.json
transforms.json文件中包含以下数据:
[
{
"CompanyTestDomain": {"QA4"},
"Environment": {"QA4.com"},
"CheckForContext": {"true"},
"ServiceTierAppHost": {"0111-06-0555-00-01.Company.com"},
"ServiceTierCsHost": {"0111-03-0444-00.Company.com"},
"ReportServer": {"0777-02-0111-00-01.Company.com"},
"ReportID": {"systemID"},
"ReportDomain": {"Corp"},
"ReportPWord": {"Password"}
}
]
执行powershell C:\Users\Public\Downloads\agent\tasks\Tokenizer\2.0.2\tokenize.ps1
下一行是灰色而不是黑色,所有其他信息都是:
##[debug]Performing the operation "Copy File" on target "Item:
C:\Agent_work\85c7a0d97\TFS Web Build 1.0\CorporateArt\app.RM.config
Destination: C:\Users\Public\Downloads\agent\tasks\Tokenizer\2.0.2\Isagenix.Clients.CorporateBackOffice.exe.config.tmp".
之后,我开始收到正在更新令牌'CompanyTestDomain'的消息 找不到令牌“CompanyTestDomain”
的值那么,有人可以帮我弄清楚我做错了吗?
答案 0 :(得分:0)
配置文件的内容应该是这样的(包含ConfigChanges部分)
例如:
来源文件内容:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="TestKey1" value="__Token1__" />
<add key="TestKey2" value="__Token2__" />
<add key="TestKey3" value="__Token3__" />
<add key="TestKey4" value="__Token4__" />
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
</startup>
</configuration>
配置文件内容:
{
"Default Environment": {
"CustomVariables": {
"Token2": "value_from_custom2",
"Token3": "value_from_custom3"
},
"ConfigChanges": [
{
"KeyName": "/configuration/appSettings/add[@key='TestKey1']",
"Attribute": "value",
"Value": "value_from_xpath"
}
]
}
}
发布定义中的变量: Token4 t4
结果:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="TestKey1" value="value_from_xpath" />
<add key="TestKey2" value="value_from_custom2" />
<add key="TestKey3" value="value_from_custom3" />
<add key="TestKey4" value="t4" />
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
</startup>
</configuration>