visual-studiomsbuildpost-build

Escaping a dollar sign in Postbuild


I'm trying to execute a command in Postbuild which uses a dollar sign. I've tried all the solutions here but none work.

echo "$(runtime.testbin)"

Trying to do this throws an exception when I try to build, I tried escaping with:

echo "%24(runtime.testbin)"

But this prints:

1> "4(runtime.testbin)"

I've also tried:

echo "%2524(runtime.testbin)"

which prints:

1> "524(runtime.testbin)"


Solution

  • You may need to encode the dollar sign and the following parenthesis (not necessarily the closing parenthesis but I personally think it looks ugly encoding just one of them):

    <PropertyGroup>
      <PostBuildEvent>echo "%24%28hello%29"</PostBuildEvent>
    </PropertyGroup>