0

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?

Daniel Mann
  • 57,011
  • 13
  • 100
  • 120
JCollier
  • 31
  • 1
  • 5
  • Do you use web-based release management or server-based release management? Which task you used? Provide the details of your release management definition. How about this task: https://marketplace.visualstudio.com/items?itemName=ms-devlabs.utilitytasks – starian chen-MSFT Dec 05 '16 at 03:21
  • I am using the web-based release management. The task is noted in the title of the post: "VS 2015 Release Management Tokenize XPath/Regular expressions" At least that's the name that comes up. I think that is the one you reference. I have a build that is linked to a release. The only task I have at the moment, is this one task. What else are you looking for in terms of definition information? – JCollier Dec 06 '16 at 15:51
  • Do you solve this issue with my solution? – starian chen-MSFT Dec 12 '16 at 06:14

1 Answers1

0

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

starian chen-MSFT
  • 33,174
  • 2
  • 29
  • 53
  • Is there an idiots guide to this? Is the first one the tokenized config file? Is the second one the json file? I have a line in a web.config that is as follows: I want to replace the __GoogleCode__ with the following: US-12349809-5 What should the json file look like? { "Default Environment": { "CustomVariables": { "GoogleCode": "US-12349809-5" } – JCollier Dec 29 '16 at 17:25
  • @JCollier The first one is your source file (web.config), the second one is the configuration file (json file). The json file should look like { "Default Environment": { "CustomVariables": { "GoogleCode": "US-12349809-5" } and web.config file likes . (This task finds the pattern ____) . Articles: https://github.com/openalm/Extension-UtilitiesPack/blob/master/Utilites/overview.md and https://the.randomengineer.com/2016/05/06/using-tokenization-token-replacement-for-buildsreleases-in-tfs-2015/ – starian chen-MSFT Dec 30 '16 at 02:23