VS 2015 Release Management Tokenize XPath/Regular expressions not working

三世轮回 提交于 2019-12-12 03:05:43

问题


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?


回答1:


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).



来源:https://stackoverflow.com/questions/40919683/vs-2015-release-management-tokenize-xpath-regular-expressions-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!