VS 2015 Release Management Tokenize XPath/正则表达式不起作用 [英] VS 2015 Release Management Tokenize XPath/Regular expressions not working

查看:32
本文介绍了VS 2015 Release Management Tokenize XPath/正则表达式不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我的配置文件设置令牌替换.我将源文件名设置为:

$(System.DefaultWorkingDirectory)/TFS Web Build 1.0/Corporate Art\app.RM.config

(这里的RM文件是使用token的token化配置文件)

目标文件名设置为配置文件的真实名称:

Company.Client.Corporate.exe.config

我在构建服务器上有 json 文件:

\0111-03-0555-01\c$\BuildFiles\Transforms.json

transforms.json 文件中包含以下数据:

<预><代码>[{"CompanyTestDomain": {"QA4"},环境":{QA4.com"},"CheckForContext": {"true"},"ServiceTierAppHost": {"0111-06-0555-00-01.Company.com"},"ServiceTierCsHost": {"0111-03-0444-00.Company.com"},"报表服务器": {"0777-02-0111-00-01.Company.com"},"ReportID": {"systemID"},"ReportDomain": {"Corp"},"ReportPWord": {"密码"}}]

执行powershell C:\Users\Public\Downloads\agent\tasks\Tokenizer\2.0.2\tokenize.ps1

下一行是灰色而不是黑色,所有其他信息都是:

##[debug]在目标项目"上执行复制文件"操作:C:\Agent_work\85c7a0d97\TFS Web Build 1.0\CorporateArt\app.RM.config目的地:C:\Users\Public\Downloads\agent\tasks\Tokenizer\2.0.2\Isagenix.Clients.CorporateBackOffice.exe.config.tmp".

之后,我开始收到消息说它正在更新令牌CompanyTestDomain"未找到令牌CompanyTestDomain"的值

那么,有人能帮我弄清楚我做错了什么吗?

解决方案

配置文件的内容应该是这样的(包含一节ConfigChanges)

例如:

源文件内容:

<add key="TestKey1" value="__Token1__"/><add key="TestKey2" value="__Token2__"/><add key="TestKey3" value="__Token3__"/><add key="TestKey4" value="__Token4__"/></appSettings><启动><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/></启动></配置>

配置文件内容:

<代码> {默认环境":{自定义变量":{"Token2": "value_from_custom2","Token3": "value_from_custom3"},配置更改":[{"KeyName": "/configuration/appSettings/add[@key='TestKey1']","属性": "值",值":value_from_xpath"}]}}

发布定义中的变量:Token4 t4

结果:

<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><启动><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/></启动></配置>

更多信息,可以查看这些文章(1, 2).

I'm trying to set up a token replacement for my config files. I have the source filename set to:

$(System.DefaultWorkingDirectory)/TFS Web Build 1.0/Corporate Art\app.RM.config

(Here, the RM file is the tokenized config file using token)

The destination filename is set to the true name of the config file:

Company.Client.Corporate.exe.config

I have the json file on the build server at:

\0111-03-0555-01\c$\BuildFiles\Transforms.json

The transforms.json file has the following data in it:

[
{
"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"}
}
]

The powershell is executed C:\Users\Public\Downloads\agent\tasks\Tokenizer\2.0.2\tokenize.ps1

The next line is grey as opposed to black which all the other information is:

##[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".

after which, I start getting messages that it's Updating token 'CompanyTestDomain' No value found for token 'CompanyTestDomain'

So, can someone help me figure out what i'm doing wrong?

解决方案

The content of configuration file should be like this (Contains a section ConfigChanges)

For example:

Sources file content:

<?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>

Configuration file content:

    {
  "Default Environment": {
    "CustomVariables": {
      "Token2": "value_from_custom2",
      "Token3": "value_from_custom3"
    },
    "ConfigChanges": [
      {
        "KeyName": "/configuration/appSettings/add[@key='TestKey1']",
        "Attribute": "value",
        "Value": "value_from_xpath"
      }
    ]
  }
}

Variable in release definition: Token4 t4

Result:

<?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>

More information, you can check these articles (1, 2).

这篇关于VS 2015 Release Management Tokenize XPath/正则表达式不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆