colindembovsky / cols-agent-tasks

Colin's ALM Corner Custom Build Tasks
MIT License
83 stars 65 forks source link

ReplaceTokens escapes (certain?) characters #120

Closed ceituna closed 5 years ago

ceituna commented 5 years ago

I'm trying to use the ReplaceTokens task in conjunction with the Tokenize Task and I've encountered a peculiar problem.

I have a variable with two adjacent dollar signs ($$) and one of them gets removed when replacing the tokens.

For example, I have the following settings in my appsettings.json after the Tokenize task runs:

{
    "SomeSetting": __SomeSetting__
}

In my Release variables I have a variable SomeSetting with the value $$. When the ReplaceTokens task runs I get following result:

{
    "SomeSetting": $
}

While I expect:

{
    "SomeSetting": $$
}
colindembovsky commented 5 years ago

Hi @ceituna - this isn't a problem with my extension, it's the way PowerShell works. $ is a special symbol in PowerShell, so if you want a literal $ in your string, you have to escape it with another $. For example, if you have P@$$w0rd as a value, when you enter it in on the Variables page of the build/release you need to make it P@$$$$w0rd. Just double the $ symbol in strings where you need the literal.