Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unexpected token "." in Exists condition

Tags:

msbuild

I have a condition looking for a path that has a "." in the file name, it looks something like this

Condition="Exists($(FirstPart).$(SecondPart))"

But I get an error saying:

"." was an unexpected token.

Any tips on how I can do this?

As far as I'm aware, . isn't a special character, and it still doesn't work when I try to escape it.

like image 852
user5816914 Avatar asked May 15 '26 17:05

user5816914


1 Answers

You might just need to add a ' on either side of your condition, like:

Condition="Exists('$(FirstPart).$(SecondPart)')"

That removed the error MSB4092: An unexpected token "." was found at character position 20 in condition "Exists($(FirstPart).$(SecondPart))" you were seeing for me.

Here is my test code:

  <Target Name="BeforeBuild" Condition="Exists('$(FirstPart).$(SecondPart)')">
    <Message Text="Hit target." />
  </Target>

And output:

  1>Target "BeforeBuild" in project "..." (entry point):
    Task "Message"
      Hit target.
    Done executing task "Message".

MSDN Reference: MSBuild Conditions

like image 156
PerryC Avatar answered May 19 '26 03:05

PerryC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!