Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to escape the dollar sign in pre-build step

'm fighting against Visual Studio to properly escape the dollar sign ($) in a pre-build step. The goal is to provide a variable name as a litteral. VS should not try to process the variable name.

The documentation states that %xx (where xx is the hexadecimal value of the character) should be used.

I've tried the following :

%24(var.Data.WebHost.ProjectDir)

But the result is

4(var.Data.WebHost.ProjectDir)

Instead of

$(var.Data.WebHost.ProjectDir)

What am I doing wrong here ?

UPDATE 1 : the correct syntax is to put the $ sign between double quotes.

"$"(var.Data.WebHost.ProjectDir)

is the answer.


1 Answers

As an alternative using the approach in the documentation would be to do:

%2524(var.Data.WebHost.ProjectDir)

%25 does the %, while the remaining 24 will be appended, forming %24, thus translating into $(Whatever) in the output code.

The "$" approach didn't work for me as I was writing an osx-compatible post build event (for mono 5), so I needed something like this:

if [ "$(uname)" == "Darwin" ]; then (...)

And the output, ""$"(uname)" didn't work for me.

I hope this late answer is helpful to anybody in the future (as there does not seem, down to this point, to have much about this issue on google).

like image 128
Fabrício Murta Avatar answered Jan 26 '26 13:01

Fabrício Murta